13603
|
1 |
--- ./libhal-glib/Makefile.am.orig 2008-09-16 10:41:55.539506000 +0800
|
|
2 |
+++ ./libhal-glib/Makefile.am 2008-09-16 10:45:00.053008000 +0800
|
|
3 |
@@ -11,11 +11,27 @@
|
|
4 |
$(top_builddir)/libdbus-glib/libdbus-proxy.la
|
|
5 |
|
|
6 |
noinst_LTLIBRARIES = \
|
|
7 |
+ libhal-gcpufreq.la \
|
|
8 |
libhal-gmanager.la \
|
|
9 |
libhal-gdevice.la \
|
|
10 |
libhal-gdevicestore.la \
|
|
11 |
libhal-gpower.la
|
|
12 |
|
|
13 |
+libhal_gcpufreq_la_SOURCES = \
|
|
14 |
+ libhal-marshal.h \
|
|
15 |
+ libhal-marshal.c \
|
|
16 |
+ libhal-gdevice.c \
|
|
17 |
+ libhal-gdevice.h \
|
|
18 |
+ libhal-gcpufreq.c \
|
|
19 |
+ libhal-gcpufreq.h \
|
|
20 |
+ libhal-gmanager.c \
|
|
21 |
+ libhal-gmanager.h
|
|
22 |
+libhal_gcpufreq_la_LIBADD = \
|
|
23 |
+ $(LOCAL_LIBDBUS_LIBS) \
|
|
24 |
+ $(DBUS_LIBS) \
|
|
25 |
+ $(INTLLIBS) \
|
|
26 |
+ $(GLIB_LIBS)
|
|
27 |
+
|
|
28 |
libhal_gmanager_la_SOURCES = \
|
|
29 |
libhal-marshal.h \
|
|
30 |
libhal-marshal.c \
|
|
31 |
--- ./libhal-glib/libhal-gcpufreq.h.orig 1970-01-01 08:00:00.000000000 +0800
|
|
32 |
+++ ./libhal-glib/libhal-gcpufreq.h 2008-09-16 10:34:25.096229000 +0800
|
|
33 |
@@ -0,0 +1,93 @@
|
|
34 |
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
|
35 |
+ *
|
|
36 |
+ * Copyright (C) 2006-2007 Richard Hughes <[email protected]>
|
|
37 |
+ *
|
|
38 |
+ * Licensed under the GNU General Public License Version 2
|
|
39 |
+ *
|
|
40 |
+ * This program is free software; you can redistribute it and/or modify
|
|
41 |
+ * it under the terms of the GNU General Public License as published by
|
|
42 |
+ * the Free Software Foundation; either version 2 of the License, or
|
|
43 |
+ * (at your option) any later version.
|
|
44 |
+ *
|
|
45 |
+ * This program is distributed in the hope that it will be useful,
|
|
46 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
47 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
48 |
+ * GNU General Public License for more details.
|
|
49 |
+ *
|
|
50 |
+ * You should have received a copy of the GNU General Public License
|
|
51 |
+ * along with this program; if not, write to the Free Software
|
|
52 |
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
53 |
+ */
|
|
54 |
+
|
|
55 |
+#ifndef __LIBHAL_GCPUFREQ_H
|
|
56 |
+#define __LIBHAL_GCPUFREQ_H
|
|
57 |
+
|
|
58 |
+#include <glib-object.h>
|
|
59 |
+
|
|
60 |
+G_BEGIN_DECLS
|
|
61 |
+
|
|
62 |
+#define LIBHAL_TYPE_CPUFREQ (hal_gcpufreq_get_type ())
|
|
63 |
+#define LIBHAL_CPUFREQ(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), LIBHAL_TYPE_CPUFREQ, HalGCpufreq))
|
|
64 |
+#define LIBHAL_CPUFREQ_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), LIBHAL_TYPE_CPUFREQ, HalGCpufreqClass))
|
|
65 |
+#define LIBHAL_IS_CPUFREQ(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), LIBHAL_TYPE_CPUFREQ))
|
|
66 |
+#define LIBHAL_IS_CPUFREQ_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), LIBHAL_TYPE_CPUFREQ))
|
|
67 |
+#define LIBHAL_CPUFREQ_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), LIBHAL_TYPE_CPUFREQ, HalGCpufreqClass))
|
|
68 |
+
|
|
69 |
+typedef struct HalGCpufreqPrivate HalGCpufreqPrivate;
|
|
70 |
+
|
|
71 |
+typedef struct
|
|
72 |
+{
|
|
73 |
+ GObject parent;
|
|
74 |
+ HalGCpufreqPrivate *priv;
|
|
75 |
+} HalGCpufreq;
|
|
76 |
+
|
|
77 |
+
|
|
78 |
+typedef struct
|
|
79 |
+{
|
|
80 |
+ GObjectClass parent_class;
|
|
81 |
+} HalGCpufreqClass;
|
|
82 |
+
|
|
83 |
+/* types of governor */
|
|
84 |
+typedef enum {
|
|
85 |
+ LIBHAL_CPUFREQ_UNKNOWN = 0,
|
|
86 |
+ LIBHAL_CPUFREQ_ONDEMAND = 1,
|
|
87 |
+ LIBHAL_CPUFREQ_CONSERVATIVE = 2,
|
|
88 |
+ LIBHAL_CPUFREQ_POWERSAVE = 4,
|
|
89 |
+ LIBHAL_CPUFREQ_USERSPACE = 8,
|
|
90 |
+ LIBHAL_CPUFREQ_PERFORMANCE = 16,
|
|
91 |
+ LIBHAL_CPUFREQ_NOTHING = 32,
|
|
92 |
+} HalGCpufreqType;
|
|
93 |
+
|
|
94 |
+#define CODE_CPUFREQ_ONDEMAND "ondemand"
|
|
95 |
+#define CODE_CPUFREQ_CONSERVATIVE "conservative"
|
|
96 |
+#define CODE_CPUFREQ_POWERSAVE "powersave"
|
|
97 |
+#define CODE_CPUFREQ_USERSPACE "userspace"
|
|
98 |
+#define CODE_CPUFREQ_PERFORMANCE "performance"
|
|
99 |
+#define CODE_CPUFREQ_NOTHING "nothing"
|
|
100 |
+
|
|
101 |
+GType hal_gcpufreq_get_type (void);
|
|
102 |
+HalGCpufreq *hal_gcpufreq_new (void);
|
|
103 |
+gboolean hal_gcpufreq_has_hw (void);
|
|
104 |
+
|
|
105 |
+const gchar *hal_gcpufreq_enum_to_string (HalGCpufreqType cpufreq_type);
|
|
106 |
+HalGCpufreqType hal_gcpufreq_string_to_enum (const gchar *governor);
|
|
107 |
+gboolean hal_gcpufreq_get_governors (HalGCpufreq *cpufreq,
|
|
108 |
+ HalGCpufreqType *cpufreq_type);
|
|
109 |
+gboolean hal_gcpufreq_get_governor (HalGCpufreq *cpufreq,
|
|
110 |
+ HalGCpufreqType *cpufreq_type);
|
|
111 |
+gboolean hal_gcpufreq_set_governor (HalGCpufreq *cpufreq,
|
|
112 |
+ HalGCpufreqType governor_enum);
|
|
113 |
+gboolean hal_gcpufreq_get_consider_nice (HalGCpufreq *cpufreq,
|
|
114 |
+ gboolean *consider_nice);
|
|
115 |
+gboolean hal_gcpufreq_set_consider_nice (HalGCpufreq *cpufreq,
|
|
116 |
+ gboolean consider_nice);
|
|
117 |
+gboolean hal_gcpufreq_get_performance (HalGCpufreq *cpufreq,
|
|
118 |
+ guint *performance);
|
|
119 |
+gboolean hal_gcpufreq_set_performance (HalGCpufreq *cpufreq,
|
|
120 |
+ guint performance);
|
|
121 |
+guint hal_gcpufreq_get_number_governors (HalGCpufreq *cpufreq,
|
|
122 |
+ gboolean use_cache);
|
|
123 |
+
|
|
124 |
+G_END_DECLS
|
|
125 |
+
|
|
126 |
+#endif /* __LIBHAL_GCPUFREQ_H */
|
|
127 |
--- ./libhal-glib/libhal-gcpufreq.c.orig 1970-01-01 08:00:00.000000000 +0800
|
|
128 |
+++ ./libhal-glib/libhal-gcpufreq.c 2008-09-16 10:34:25.096051000 +0800
|
|
129 |
@@ -0,0 +1,608 @@
|
|
130 |
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
|
131 |
+ *
|
|
132 |
+ * Copyright (C) 2006-2007 Richard Hughes <[email protected]>
|
|
133 |
+ *
|
|
134 |
+ * Licensed under the GNU General Public License Version 2
|
|
135 |
+ *
|
|
136 |
+ * This program is free software; you can redistribute it and/or modify
|
|
137 |
+ * it under the terms of the GNU General Public License as published by
|
|
138 |
+ * the Free Software Foundation; either version 2 of the License, or
|
|
139 |
+ * (at your option) any later version.
|
|
140 |
+ *
|
|
141 |
+ * This program is distributed in the hope that it will be useful,
|
|
142 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
143 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
144 |
+ * GNU General Public License for more details.
|
|
145 |
+ *
|
|
146 |
+ * You should have received a copy of the GNU General Public License
|
|
147 |
+ * along with this program; if not, write to the Free Software
|
|
148 |
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
149 |
+ */
|
|
150 |
+
|
|
151 |
+#ifdef HAVE_CONFIG_H
|
|
152 |
+# include <config.h>
|
|
153 |
+#endif
|
|
154 |
+
|
|
155 |
+#include <string.h>
|
|
156 |
+#include <glib.h>
|
|
157 |
+#include <dbus/dbus-glib.h>
|
|
158 |
+#include <glib/gi18n.h>
|
|
159 |
+#include <libdbus-proxy.h>
|
|
160 |
+
|
|
161 |
+#include "libhal-marshal.h"
|
|
162 |
+#include "libhal-gpower.h"
|
|
163 |
+#include "libhal-gdevice.h"
|
|
164 |
+#include "libhal-gcpufreq.h"
|
|
165 |
+#include "libhal-gmanager.h"
|
|
166 |
+
|
|
167 |
+static void hal_gcpufreq_class_init (HalGCpufreqClass *klass);
|
|
168 |
+static void hal_gcpufreq_init (HalGCpufreq *hal);
|
|
169 |
+static void hal_gcpufreq_finalize (GObject *object);
|
|
170 |
+
|
|
171 |
+#define LIBHAL_CPUFREQ_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), LIBHAL_TYPE_CPUFREQ, HalGCpufreqPrivate))
|
|
172 |
+
|
|
173 |
+struct HalGCpufreqPrivate
|
|
174 |
+{
|
|
175 |
+ DbusProxy *gproxy;
|
|
176 |
+ guint available_governors;
|
|
177 |
+ HalGCpufreqType current_governor;
|
|
178 |
+};
|
|
179 |
+
|
|
180 |
+G_DEFINE_TYPE (HalGCpufreq, hal_gcpufreq, G_TYPE_OBJECT)
|
|
181 |
+
|
|
182 |
+static gpointer hal_gcpufreq_object = NULL;
|
|
183 |
+
|
|
184 |
+/**
|
|
185 |
+ * hal_gcpufreq_string_to_enum:
|
|
186 |
+ * @governor: The cpufreq kernel governor, e.g. "powersave"
|
|
187 |
+ * Return value: The HalGCpufreqType value, e.g. LIBHAL_CPUFREQ_POWERSAVE
|
|
188 |
+ **/
|
|
189 |
+HalGCpufreqType
|
|
190 |
+hal_gcpufreq_string_to_enum (const gchar *governor)
|
|
191 |
+{
|
|
192 |
+ HalGCpufreqType cpufreq_type = LIBHAL_CPUFREQ_UNKNOWN;
|
|
193 |
+ if (governor == NULL) {
|
|
194 |
+ cpufreq_type = LIBHAL_CPUFREQ_NOTHING;
|
|
195 |
+ } else if (strcmp (governor, CODE_CPUFREQ_ONDEMAND) == 0) {
|
|
196 |
+ cpufreq_type = LIBHAL_CPUFREQ_ONDEMAND;
|
|
197 |
+ } else if (strcmp (governor, CODE_CPUFREQ_CONSERVATIVE) == 0) {
|
|
198 |
+ cpufreq_type = LIBHAL_CPUFREQ_CONSERVATIVE;
|
|
199 |
+ } else if (strcmp (governor, CODE_CPUFREQ_POWERSAVE) == 0) {
|
|
200 |
+ cpufreq_type = LIBHAL_CPUFREQ_POWERSAVE;
|
|
201 |
+ } else if (strcmp (governor, CODE_CPUFREQ_USERSPACE) == 0) {
|
|
202 |
+ cpufreq_type = LIBHAL_CPUFREQ_USERSPACE;
|
|
203 |
+ } else if (strcmp (governor, CODE_CPUFREQ_PERFORMANCE) == 0) {
|
|
204 |
+ cpufreq_type = LIBHAL_CPUFREQ_PERFORMANCE;
|
|
205 |
+ } else if (strcmp (governor, CODE_CPUFREQ_NOTHING) == 0) {
|
|
206 |
+ cpufreq_type = LIBHAL_CPUFREQ_NOTHING;
|
|
207 |
+ }
|
|
208 |
+ return cpufreq_type;
|
|
209 |
+}
|
|
210 |
+
|
|
211 |
+/**
|
|
212 |
+ * hal_gcpufreq_string_to_enum:
|
|
213 |
+ * @cpufreq_type: The HalGCpufreqType value, e.g. LIBHAL_CPUFREQ_POWERSAVE
|
|
214 |
+ * Return value: The cpufreq kernel governor, e.g. "powersave"
|
|
215 |
+ **/
|
|
216 |
+const gchar *
|
|
217 |
+hal_gcpufreq_enum_to_string (HalGCpufreqType cpufreq_type)
|
|
218 |
+{
|
|
219 |
+ const char *governor;
|
|
220 |
+ if (cpufreq_type == LIBHAL_CPUFREQ_ONDEMAND) {
|
|
221 |
+ governor = CODE_CPUFREQ_ONDEMAND;
|
|
222 |
+ } else if (cpufreq_type == LIBHAL_CPUFREQ_CONSERVATIVE) {
|
|
223 |
+ governor = CODE_CPUFREQ_CONSERVATIVE;
|
|
224 |
+ } else if (cpufreq_type == LIBHAL_CPUFREQ_POWERSAVE) {
|
|
225 |
+ governor = CODE_CPUFREQ_POWERSAVE;
|
|
226 |
+ } else if (cpufreq_type == LIBHAL_CPUFREQ_USERSPACE) {
|
|
227 |
+ governor = CODE_CPUFREQ_USERSPACE;
|
|
228 |
+ } else if (cpufreq_type == LIBHAL_CPUFREQ_PERFORMANCE) {
|
|
229 |
+ governor = CODE_CPUFREQ_PERFORMANCE;
|
|
230 |
+ } else if (cpufreq_type == LIBHAL_CPUFREQ_NOTHING) {
|
|
231 |
+ governor = CODE_CPUFREQ_NOTHING;
|
|
232 |
+ } else {
|
|
233 |
+ governor = "unknown";
|
|
234 |
+ }
|
|
235 |
+ return governor;
|
|
236 |
+}
|
|
237 |
+
|
|
238 |
+/**
|
|
239 |
+ * hal_gcpufreq_set_performance:
|
|
240 |
+ *
|
|
241 |
+ * @cpufreq: This class instance
|
|
242 |
+ * @performance: The percentage perfomance figure
|
|
243 |
+ * Return value: If the method succeeded
|
|
244 |
+ **/
|
|
245 |
+gboolean
|
|
246 |
+hal_gcpufreq_set_performance (HalGCpufreq *cpufreq, guint performance)
|
|
247 |
+{
|
|
248 |
+ GError *error = NULL;
|
|
249 |
+ gboolean ret;
|
|
250 |
+ HalGCpufreqType cpufreq_type;
|
|
251 |
+ DBusGProxy *proxy;
|
|
252 |
+
|
|
253 |
+ g_return_val_if_fail (cpufreq != NULL, FALSE);
|
|
254 |
+ g_return_val_if_fail (LIBHAL_IS_CPUFREQ (cpufreq), FALSE);
|
|
255 |
+ g_return_val_if_fail (performance >= 0, FALSE);
|
|
256 |
+ g_return_val_if_fail (performance <= 100, FALSE);
|
|
257 |
+
|
|
258 |
+ /* we need to find the current governor to see if it's sane */
|
|
259 |
+ if (cpufreq->priv->current_governor == LIBHAL_CPUFREQ_UNKNOWN) {
|
|
260 |
+ hal_gcpufreq_get_governor (cpufreq, &cpufreq_type);
|
|
261 |
+ }
|
|
262 |
+
|
|
263 |
+ /* only applies to some governors */
|
|
264 |
+ if (cpufreq->priv->current_governor == LIBHAL_CPUFREQ_PERFORMANCE ||
|
|
265 |
+ cpufreq->priv->current_governor == LIBHAL_CPUFREQ_POWERSAVE) {
|
|
266 |
+ return FALSE;
|
|
267 |
+ }
|
|
268 |
+
|
|
269 |
+ proxy = dbus_proxy_get_proxy (cpufreq->priv->gproxy);
|
|
270 |
+ if (proxy == NULL) {
|
|
271 |
+ g_warning ("not connected");
|
|
272 |
+ return FALSE;
|
|
273 |
+ }
|
|
274 |
+
|
|
275 |
+ ret = dbus_g_proxy_call (proxy, "SetCPUFreqPerformance", &error,
|
|
276 |
+ G_TYPE_INT, performance,
|
|
277 |
+ G_TYPE_INVALID,
|
|
278 |
+ G_TYPE_INVALID);
|
|
279 |
+ if (error) {
|
|
280 |
+ g_warning ("ERROR: %s", error->message);
|
|
281 |
+ g_error_free (error);
|
|
282 |
+ }
|
|
283 |
+ if (ret == FALSE) {
|
|
284 |
+ /* abort as the DBUS method failed */
|
|
285 |
+ return FALSE;
|
|
286 |
+ }
|
|
287 |
+ return TRUE;
|
|
288 |
+}
|
|
289 |
+
|
|
290 |
+/**
|
|
291 |
+ * hal_gcpufreq_set_governor:
|
|
292 |
+ *
|
|
293 |
+ * @cpufreq: This class instance
|
|
294 |
+ * @cpufreq_type: The CPU governor type, e.g. LIBHAL_CPUFREQ_CONSERVATIVE
|
|
295 |
+ * Return value: If the method succeeded
|
|
296 |
+ **/
|
|
297 |
+gboolean
|
|
298 |
+hal_gcpufreq_set_governor (HalGCpufreq *cpufreq,
|
|
299 |
+ HalGCpufreqType cpufreq_type)
|
|
300 |
+{
|
|
301 |
+ GError *error = NULL;
|
|
302 |
+ gboolean ret;
|
|
303 |
+ const gchar *governor;
|
|
304 |
+ DBusGProxy *proxy;
|
|
305 |
+
|
|
306 |
+ g_return_val_if_fail (cpufreq != NULL, FALSE);
|
|
307 |
+ g_return_val_if_fail (LIBHAL_IS_CPUFREQ (cpufreq), FALSE);
|
|
308 |
+ g_return_val_if_fail (cpufreq_type != LIBHAL_CPUFREQ_UNKNOWN, FALSE);
|
|
309 |
+
|
|
310 |
+ governor = hal_gcpufreq_enum_to_string (cpufreq_type);
|
|
311 |
+ g_return_val_if_fail (governor != NULL, FALSE);
|
|
312 |
+
|
|
313 |
+ proxy = dbus_proxy_get_proxy (cpufreq->priv->gproxy);
|
|
314 |
+ if (proxy == NULL) {
|
|
315 |
+ g_warning ("not connected");
|
|
316 |
+ return FALSE;
|
|
317 |
+ }
|
|
318 |
+
|
|
319 |
+ ret = dbus_g_proxy_call (proxy, "SetCPUFreqGovernor", &error,
|
|
320 |
+ G_TYPE_STRING, governor,
|
|
321 |
+ G_TYPE_INVALID,
|
|
322 |
+ G_TYPE_INVALID);
|
|
323 |
+ if (error) {
|
|
324 |
+ g_warning ("ERROR: %s", error->message);
|
|
325 |
+ g_error_free (error);
|
|
326 |
+ }
|
|
327 |
+ if (ret == FALSE) {
|
|
328 |
+ /* abort as the DBUS method failed */
|
|
329 |
+ return FALSE;
|
|
330 |
+ }
|
|
331 |
+
|
|
332 |
+ /* save the cache */
|
|
333 |
+ cpufreq->priv->current_governor = cpufreq_type;
|
|
334 |
+ return TRUE;
|
|
335 |
+}
|
|
336 |
+
|
|
337 |
+/**
|
|
338 |
+ * hal_gcpufreq_get_governors:
|
|
339 |
+ *
|
|
340 |
+ * @cpufreq: This class instance
|
|
341 |
+ * @cpufreq_type: Return variable, The CPU governor type as an combined bitwise type
|
|
342 |
+ * Return value: If the method succeeded
|
|
343 |
+ **/
|
|
344 |
+gboolean
|
|
345 |
+hal_gcpufreq_get_governors (HalGCpufreq *cpufreq,
|
|
346 |
+ HalGCpufreqType *cpufreq_type)
|
|
347 |
+{
|
|
348 |
+ GError *error = NULL;
|
|
349 |
+ gboolean ret;
|
|
350 |
+ char **strlist;
|
|
351 |
+ int i = 0;
|
|
352 |
+ DBusGProxy *proxy;
|
|
353 |
+ HalGCpufreqType types = LIBHAL_CPUFREQ_UNKNOWN;
|
|
354 |
+
|
|
355 |
+ g_return_val_if_fail (cpufreq != NULL, FALSE);
|
|
356 |
+ g_return_val_if_fail (LIBHAL_IS_CPUFREQ (cpufreq), FALSE);
|
|
357 |
+ g_return_val_if_fail (cpufreq_type != NULL, FALSE);
|
|
358 |
+
|
|
359 |
+ proxy = dbus_proxy_get_proxy (cpufreq->priv->gproxy);
|
|
360 |
+ if (proxy == NULL) {
|
|
361 |
+ g_warning ("not connected");
|
|
362 |
+ *cpufreq_type = LIBHAL_CPUFREQ_UNKNOWN;
|
|
363 |
+ return FALSE;
|
|
364 |
+ }
|
|
365 |
+
|
|
366 |
+ ret = dbus_g_proxy_call (proxy, "GetCPUFreqAvailableGovernors", &error,
|
|
367 |
+ G_TYPE_INVALID,
|
|
368 |
+ G_TYPE_STRV, &strlist,
|
|
369 |
+ G_TYPE_INVALID);
|
|
370 |
+ if (error) {
|
|
371 |
+ g_warning ("ERROR: %s", error->message);
|
|
372 |
+ g_error_free (error);
|
|
373 |
+ }
|
|
374 |
+ if (ret == FALSE) {
|
|
375 |
+ /* abort as the DBUS method failed */
|
|
376 |
+ *cpufreq_type = LIBHAL_CPUFREQ_UNKNOWN;
|
|
377 |
+ return FALSE;
|
|
378 |
+ }
|
|
379 |
+
|
|
380 |
+ /* treat as binary flags */
|
|
381 |
+ while (strlist && strlist[i]) {
|
|
382 |
+ types += hal_gcpufreq_string_to_enum (strlist[i]);
|
|
383 |
+ ++i;
|
|
384 |
+ }
|
|
385 |
+
|
|
386 |
+ /* when we have conservative and ondemand available, only expose
|
|
387 |
+ ondemand in the UI. They are too similar and ondemand is better. */
|
|
388 |
+ if (types & LIBHAL_CPUFREQ_ONDEMAND && types & LIBHAL_CPUFREQ_CONSERVATIVE) {
|
|
389 |
+ types -= LIBHAL_CPUFREQ_CONSERVATIVE;
|
|
390 |
+ }
|
|
391 |
+
|
|
392 |
+ /* We never allow the user to use userspace. */
|
|
393 |
+ if (types & LIBHAL_CPUFREQ_USERSPACE) {
|
|
394 |
+ types -= LIBHAL_CPUFREQ_USERSPACE;
|
|
395 |
+ }
|
|
396 |
+
|
|
397 |
+ *cpufreq_type = types;
|
|
398 |
+ cpufreq->priv->available_governors = i;
|
|
399 |
+ return TRUE;
|
|
400 |
+}
|
|
401 |
+
|
|
402 |
+/**
|
|
403 |
+ * hal_gcpufreq_get_number_governors:
|
|
404 |
+ *
|
|
405 |
+ * @cpufreq: This class instance
|
|
406 |
+ * @use_cache: if we should force a cache update
|
|
407 |
+ * Return value: the number of available governors
|
|
408 |
+ **/
|
|
409 |
+guint
|
|
410 |
+hal_gcpufreq_get_number_governors (HalGCpufreq *cpufreq,
|
|
411 |
+ gboolean use_cache)
|
|
412 |
+{
|
|
413 |
+ HalGCpufreqType cpufreq_type;
|
|
414 |
+
|
|
415 |
+ g_return_val_if_fail (cpufreq != NULL, FALSE);
|
|
416 |
+ g_return_val_if_fail (LIBHAL_IS_CPUFREQ (cpufreq), FALSE);
|
|
417 |
+
|
|
418 |
+ if (use_cache == FALSE || cpufreq->priv->available_governors == -1) {
|
|
419 |
+ hal_gcpufreq_get_governors (cpufreq, &cpufreq_type);
|
|
420 |
+ }
|
|
421 |
+ return cpufreq->priv->available_governors;
|
|
422 |
+}
|
|
423 |
+
|
|
424 |
+/**
|
|
425 |
+ * hal_gcpufreq_get_consider_nice:
|
|
426 |
+ *
|
|
427 |
+ * @cpufreq: This class instance
|
|
428 |
+ * @consider_nice: Return variable, if consider niced processes
|
|
429 |
+ * Return value: If the method succeeded
|
|
430 |
+ **/
|
|
431 |
+gboolean
|
|
432 |
+hal_gcpufreq_get_consider_nice (HalGCpufreq *cpufreq,
|
|
433 |
+ gboolean *consider_nice)
|
|
434 |
+{
|
|
435 |
+ GError *error = NULL;
|
|
436 |
+ gboolean ret;
|
|
437 |
+ HalGCpufreqType cpufreq_type;
|
|
438 |
+ DBusGProxy *proxy;
|
|
439 |
+
|
|
440 |
+ g_return_val_if_fail (cpufreq != NULL, FALSE);
|
|
441 |
+ g_return_val_if_fail (LIBHAL_IS_CPUFREQ (cpufreq), FALSE);
|
|
442 |
+ g_return_val_if_fail (consider_nice != NULL, FALSE);
|
|
443 |
+
|
|
444 |
+ /* we need to find the current governor to see if it's sane */
|
|
445 |
+ if (cpufreq->priv->current_governor == LIBHAL_CPUFREQ_UNKNOWN) {
|
|
446 |
+ hal_gcpufreq_get_governor (cpufreq, &cpufreq_type);
|
|
447 |
+ }
|
|
448 |
+
|
|
449 |
+ /* only applies to some governors */
|
|
450 |
+ if (cpufreq->priv->current_governor != LIBHAL_CPUFREQ_ONDEMAND &&
|
|
451 |
+ cpufreq->priv->current_governor != LIBHAL_CPUFREQ_CONSERVATIVE) {
|
|
452 |
+ *consider_nice = FALSE;
|
|
453 |
+ return FALSE;
|
|
454 |
+ }
|
|
455 |
+
|
|
456 |
+ proxy = dbus_proxy_get_proxy (cpufreq->priv->gproxy);
|
|
457 |
+ if (proxy == NULL) {
|
|
458 |
+ g_warning ("not connected");
|
|
459 |
+ return FALSE;
|
|
460 |
+ }
|
|
461 |
+
|
|
462 |
+ ret = dbus_g_proxy_call (proxy, "GetCPUFreqConsiderNice", &error,
|
|
463 |
+ G_TYPE_INVALID,
|
|
464 |
+ G_TYPE_BOOLEAN, consider_nice,
|
|
465 |
+ G_TYPE_INVALID);
|
|
466 |
+ if (error) {
|
|
467 |
+ g_warning ("ERROR: %s", error->message);
|
|
468 |
+ g_error_free (error);
|
|
469 |
+ }
|
|
470 |
+ if (ret == FALSE) {
|
|
471 |
+ /* abort as the DBUS method failed */
|
|
472 |
+ return FALSE;
|
|
473 |
+ }
|
|
474 |
+ return TRUE;
|
|
475 |
+}
|
|
476 |
+
|
|
477 |
+/**
|
|
478 |
+ * hal_gcpufreq_get_performance:
|
|
479 |
+ *
|
|
480 |
+ * @cpufreq: This class instance
|
|
481 |
+ * @performance: Return variable, the percentage performance
|
|
482 |
+ * Return value: If the method succeeded
|
|
483 |
+ **/
|
|
484 |
+gboolean
|
|
485 |
+hal_gcpufreq_get_performance (HalGCpufreq *cpufreq,
|
|
486 |
+ guint *performance)
|
|
487 |
+{
|
|
488 |
+ GError *error = NULL;
|
|
489 |
+ gboolean ret;
|
|
490 |
+ HalGCpufreqType cpufreq_type;
|
|
491 |
+ DBusGProxy *proxy;
|
|
492 |
+
|
|
493 |
+ g_return_val_if_fail (cpufreq != NULL, FALSE);
|
|
494 |
+ g_return_val_if_fail (LIBHAL_IS_CPUFREQ (cpufreq), FALSE);
|
|
495 |
+ g_return_val_if_fail (performance != NULL, FALSE);
|
|
496 |
+
|
|
497 |
+ /* we need to find the current governor to see if it's sane */
|
|
498 |
+ if (cpufreq->priv->current_governor == LIBHAL_CPUFREQ_UNKNOWN) {
|
|
499 |
+ hal_gcpufreq_get_governor (cpufreq, &cpufreq_type);
|
|
500 |
+ }
|
|
501 |
+
|
|
502 |
+ /* only applies to some governors */
|
|
503 |
+ if (cpufreq->priv->current_governor != LIBHAL_CPUFREQ_USERSPACE) {
|
|
504 |
+ *performance = -1;
|
|
505 |
+ return FALSE;
|
|
506 |
+ }
|
|
507 |
+
|
|
508 |
+ proxy = dbus_proxy_get_proxy (cpufreq->priv->gproxy);
|
|
509 |
+ if (proxy == NULL) {
|
|
510 |
+ g_warning ("not connected");
|
|
511 |
+ return FALSE;
|
|
512 |
+ }
|
|
513 |
+
|
|
514 |
+ ret = dbus_g_proxy_call (proxy, "GetCPUFreqPerformance", &error,
|
|
515 |
+ G_TYPE_INVALID,
|
|
516 |
+ G_TYPE_INT, performance,
|
|
517 |
+ G_TYPE_INVALID);
|
|
518 |
+ if (error) {
|
|
519 |
+ g_warning ("ERROR: %s", error->message);
|
|
520 |
+ g_error_free (error);
|
|
521 |
+ }
|
|
522 |
+ if (ret == FALSE) {
|
|
523 |
+ /* abort as the DBUS method failed */
|
|
524 |
+ return FALSE;
|
|
525 |
+ }
|
|
526 |
+ return TRUE;
|
|
527 |
+}
|
|
528 |
+
|
|
529 |
+/**
|
|
530 |
+ * hal_gcpufreq_get_governor:
|
|
531 |
+ *
|
|
532 |
+ * @cpufreq: This class instance
|
|
533 |
+ * @cpufreq_type: Return variable, the governor type, e.g. LIBHAL_CPUFREQ_POWERSAVE
|
|
534 |
+ * Return value: If the method succeeded
|
|
535 |
+ **/
|
|
536 |
+gboolean
|
|
537 |
+hal_gcpufreq_get_governor (HalGCpufreq *cpufreq,
|
|
538 |
+ HalGCpufreqType *cpufreq_type)
|
|
539 |
+{
|
|
540 |
+ GError *error = NULL;
|
|
541 |
+ gboolean ret;
|
|
542 |
+ gchar *governor;
|
|
543 |
+ DBusGProxy *proxy;
|
|
544 |
+
|
|
545 |
+ g_return_val_if_fail (cpufreq != NULL, FALSE);
|
|
546 |
+ g_return_val_if_fail (LIBHAL_IS_CPUFREQ (cpufreq), FALSE);
|
|
547 |
+ g_return_val_if_fail (cpufreq_type, FALSE);
|
|
548 |
+
|
|
549 |
+ *cpufreq_type = LIBHAL_CPUFREQ_UNKNOWN;
|
|
550 |
+
|
|
551 |
+ /* use the cache */
|
|
552 |
+ if (cpufreq->priv->current_governor != LIBHAL_CPUFREQ_UNKNOWN) {
|
|
553 |
+ return cpufreq->priv->current_governor;
|
|
554 |
+ }
|
|
555 |
+
|
|
556 |
+ proxy = dbus_proxy_get_proxy (cpufreq->priv->gproxy);
|
|
557 |
+ if (proxy == NULL) {
|
|
558 |
+ g_warning ("not connected");
|
|
559 |
+ return FALSE;
|
|
560 |
+ }
|
|
561 |
+
|
|
562 |
+ ret = dbus_g_proxy_call (proxy, "GetCPUFreqGovernor", &error,
|
|
563 |
+ G_TYPE_INVALID,
|
|
564 |
+ G_TYPE_STRING, &governor,
|
|
565 |
+ G_TYPE_INVALID);
|
|
566 |
+ if (error) {
|
|
567 |
+ g_warning ("ERROR: %s", error->message);
|
|
568 |
+ g_error_free (error);
|
|
569 |
+ }
|
|
570 |
+ if (ret == FALSE) {
|
|
571 |
+ /* abort as the DBUS method failed */
|
|
572 |
+ return FALSE;
|
|
573 |
+ }
|
|
574 |
+
|
|
575 |
+ /* convert to enumerated type */
|
|
576 |
+ if (governor != NULL) {
|
|
577 |
+ *cpufreq_type = hal_gcpufreq_string_to_enum (governor);
|
|
578 |
+ cpufreq->priv->current_governor = *cpufreq_type;
|
|
579 |
+ g_free (governor);
|
|
580 |
+ }
|
|
581 |
+
|
|
582 |
+ return TRUE;
|
|
583 |
+}
|
|
584 |
+
|
|
585 |
+/**
|
|
586 |
+ * hal_gcpufreq_set_consider_nice:
|
|
587 |
+ *
|
|
588 |
+ * @cpufreq: This class instance
|
|
589 |
+ * @enable: True to consider nice processes
|
|
590 |
+ * Return value: If the method succeeded
|
|
591 |
+ **/
|
|
592 |
+gboolean
|
|
593 |
+hal_gcpufreq_set_consider_nice (HalGCpufreq *cpufreq,
|
|
594 |
+ gboolean consider_nice)
|
|
595 |
+{
|
|
596 |
+ GError *error = NULL;
|
|
597 |
+ gboolean ret;
|
|
598 |
+ HalGCpufreqType cpufreq_type;
|
|
599 |
+ DBusGProxy *proxy;
|
|
600 |
+
|
|
601 |
+ g_return_val_if_fail (cpufreq != NULL, FALSE);
|
|
602 |
+ g_return_val_if_fail (LIBHAL_IS_CPUFREQ (cpufreq), FALSE);
|
|
603 |
+
|
|
604 |
+ /* we need to find the current governor to see if it's sane */
|
|
605 |
+ if (cpufreq->priv->current_governor == LIBHAL_CPUFREQ_UNKNOWN) {
|
|
606 |
+ hal_gcpufreq_get_governor (cpufreq, &cpufreq_type);
|
|
607 |
+ }
|
|
608 |
+
|
|
609 |
+ /* only applies to some governors */
|
|
610 |
+ if (cpufreq->priv->current_governor != LIBHAL_CPUFREQ_ONDEMAND &&
|
|
611 |
+ cpufreq->priv->current_governor != LIBHAL_CPUFREQ_CONSERVATIVE) {
|
|
612 |
+ return FALSE;
|
|
613 |
+ }
|
|
614 |
+
|
|
615 |
+ proxy = dbus_proxy_get_proxy (cpufreq->priv->gproxy);
|
|
616 |
+ if (proxy == NULL) {
|
|
617 |
+ g_warning ("not connected");
|
|
618 |
+ return FALSE;
|
|
619 |
+ }
|
|
620 |
+
|
|
621 |
+ ret = dbus_g_proxy_call (proxy, "SetCPUFreqConsiderNice", &error,
|
|
622 |
+ G_TYPE_BOOLEAN, consider_nice,
|
|
623 |
+ G_TYPE_INVALID,
|
|
624 |
+ G_TYPE_INVALID);
|
|
625 |
+ if (error) {
|
|
626 |
+ g_warning ("ERROR: %s", error->message);
|
|
627 |
+ g_error_free (error);
|
|
628 |
+ }
|
|
629 |
+ if (ret == FALSE) {
|
|
630 |
+ /* abort as the DBUS method failed */
|
|
631 |
+ return FALSE;
|
|
632 |
+ }
|
|
633 |
+ return TRUE;
|
|
634 |
+}
|
|
635 |
+
|
|
636 |
+/**
|
|
637 |
+ * hal_gcpufreq_class_init:
|
|
638 |
+ * @klass: This class instance
|
|
639 |
+ **/
|
|
640 |
+static void
|
|
641 |
+hal_gcpufreq_class_init (HalGCpufreqClass *klass)
|
|
642 |
+{
|
|
643 |
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
644 |
+ object_class->finalize = hal_gcpufreq_finalize;
|
|
645 |
+ g_type_class_add_private (klass, sizeof (HalGCpufreqPrivate));
|
|
646 |
+}
|
|
647 |
+
|
|
648 |
+/**
|
|
649 |
+ * hal_gcpufreq_init:
|
|
650 |
+ *
|
|
651 |
+ * @cpufreq: This class instance
|
|
652 |
+ **/
|
|
653 |
+static void
|
|
654 |
+hal_gcpufreq_init (HalGCpufreq *cpufreq)
|
|
655 |
+{
|
|
656 |
+ cpufreq->priv = LIBHAL_CPUFREQ_GET_PRIVATE (cpufreq);
|
|
657 |
+
|
|
658 |
+ cpufreq->priv->gproxy = dbus_proxy_new ();
|
|
659 |
+ dbus_proxy_assign (cpufreq->priv->gproxy,
|
|
660 |
+ DBUS_PROXY_SYSTEM,
|
|
661 |
+ HAL_DBUS_SERVICE,
|
|
662 |
+ HAL_ROOT_COMPUTER,
|
|
663 |
+ HAL_DBUS_INTERFACE_CPUFREQ);
|
|
664 |
+
|
|
665 |
+ /* set defaults */
|
|
666 |
+ cpufreq->priv->available_governors = -1;
|
|
667 |
+ cpufreq->priv->current_governor = LIBHAL_CPUFREQ_UNKNOWN;
|
|
668 |
+}
|
|
669 |
+
|
|
670 |
+/**
|
|
671 |
+ * hal_gcpufreq_finalize:
|
|
672 |
+ * @object: This class instance
|
|
673 |
+ **/
|
|
674 |
+static void
|
|
675 |
+hal_gcpufreq_finalize (GObject *object)
|
|
676 |
+{
|
|
677 |
+ HalGCpufreq *cpufreq;
|
|
678 |
+ g_return_if_fail (object != NULL);
|
|
679 |
+ g_return_if_fail (LIBHAL_IS_CPUFREQ (object));
|
|
680 |
+
|
|
681 |
+ cpufreq = LIBHAL_CPUFREQ (object);
|
|
682 |
+ cpufreq->priv = LIBHAL_CPUFREQ_GET_PRIVATE (cpufreq);
|
|
683 |
+
|
|
684 |
+ if (cpufreq->priv->gproxy != NULL) {
|
|
685 |
+ g_object_unref (cpufreq->priv->gproxy);
|
|
686 |
+ }
|
|
687 |
+
|
|
688 |
+ G_OBJECT_CLASS (hal_gcpufreq_parent_class)->finalize (object);
|
|
689 |
+}
|
|
690 |
+
|
|
691 |
+/**
|
|
692 |
+ * hal_gcpufreq_has_hw:
|
|
693 |
+ *
|
|
694 |
+ * Self contained function that works out if we have the hardware.
|
|
695 |
+ * If not, we return FALSE and the module is unloaded.
|
|
696 |
+ **/
|
|
697 |
+gboolean
|
|
698 |
+hal_gcpufreq_has_hw (void)
|
|
699 |
+{
|
|
700 |
+ HalGManager *hal_manager;
|
|
701 |
+ gchar **names;
|
|
702 |
+ gboolean ret = TRUE;
|
|
703 |
+
|
|
704 |
+ /* okay, as singleton */
|
|
705 |
+ hal_manager = hal_gmanager_new ();
|
|
706 |
+ ret = hal_gmanager_find_capability (hal_manager, "cpufreq_control", &names, NULL);
|
|
707 |
+
|
|
708 |
+ /* nothing found */
|
|
709 |
+ if (names == NULL || names[0] == NULL) {
|
|
710 |
+ ret = FALSE;
|
|
711 |
+ }
|
|
712 |
+ hal_gmanager_free_capability (names);
|
|
713 |
+ g_object_unref (hal_manager);
|
|
714 |
+
|
|
715 |
+ return ret;
|
|
716 |
+}
|
|
717 |
+
|
|
718 |
+/**
|
|
719 |
+ * hal_gcpufreq_new:
|
|
720 |
+ * Return value: new HalGCpufreq instance.
|
|
721 |
+ **/
|
|
722 |
+HalGCpufreq *
|
|
723 |
+hal_gcpufreq_new (void)
|
|
724 |
+{
|
|
725 |
+ if (hal_gcpufreq_object != NULL) {
|
|
726 |
+ g_object_ref (hal_gcpufreq_object);
|
|
727 |
+ } else {
|
|
728 |
+ /* only load an instance of this module if we have the hardware */
|
|
729 |
+ if (hal_gcpufreq_has_hw () == FALSE) {
|
|
730 |
+ return NULL;
|
|
731 |
+ }
|
|
732 |
+ hal_gcpufreq_object = g_object_new (LIBHAL_TYPE_CPUFREQ, NULL);
|
|
733 |
+ g_object_add_weak_pointer (hal_gcpufreq_object, &hal_gcpufreq_object);
|
|
734 |
+ }
|
|
735 |
+ return LIBHAL_CPUFREQ (hal_gcpufreq_object);
|
|
736 |
+}
|
|
737 |
+
|
|
738 |
--- data/gnome-power-manager.schemas.in.orig 2008-09-16 13:26:20.971533000 +0800
|
|
739 |
+++ data/gnome-power-manager.schemas.in 2008-09-16 13:27:40.434145000 +0800
|
|
740 |
@@ -300,6 +300,66 @@
|
|
741 |
</schema>
|
|
742 |
|
|
743 |
<schema>
|
|
744 |
+ <key>/schemas/apps/gnome-power-manager/cpufreq/consider_nice</key>
|
|
745 |
+ <applyto>/apps/gnome-power-manager/cpufreq/consider_nice</applyto>
|
|
746 |
+ <owner>gnome-power-manager</owner>
|
|
747 |
+ <type>bool</type>
|
|
748 |
+ <default>false</default>
|
|
749 |
+ <locale name="C">
|
|
750 |
+ <short>Whether or not niced processes should be considered on processor load calculation</short>
|
|
751 |
+ <long>If niced processes are considered, they can cause a frequency increment even though their absolute load percentage wouldn't trigger the scaling mechanism to switch up the frequency.</long>
|
|
752 |
+ </locale>
|
|
753 |
+ </schema>
|
|
754 |
+
|
|
755 |
+ <schema>
|
|
756 |
+ <key>/schemas/apps/gnome-power-manager/cpufreq/policy_ac</key>
|
|
757 |
+ <applyto>/apps/gnome-power-manager/cpufreq/policy_ac</applyto>
|
|
758 |
+ <owner>gnome-power-manager</owner>
|
|
759 |
+ <type>string</type>
|
|
760 |
+ <default>nothing</default>
|
|
761 |
+ <locale name="C">
|
|
762 |
+ <short>The cpufreq policy to use when on AC power</short>
|
|
763 |
+ <long>The cpufreq policy used to scale the processor when on AC power. Possible values are ondemand, conservative, powersave, userspace, performance, nothing.</long>
|
|
764 |
+ </locale>
|
|
765 |
+ </schema>
|
|
766 |
+
|
|
767 |
+ <schema>
|
|
768 |
+ <key>/schemas/apps/gnome-power-manager/cpufreq/performance_ac</key>
|
|
769 |
+ <applyto>/apps/gnome-power-manager/cpufreq/performance_ac</applyto>
|
|
770 |
+ <owner>gnome-power-manager</owner>
|
|
771 |
+ <type>int</type>
|
|
772 |
+ <default>85</default>
|
|
773 |
+ <locale name="C">
|
|
774 |
+ <short>The cpufreq performance value to use when on AC power</short>
|
|
775 |
+ <long>The cpufreq performance value used to scale the processor when on AC power.</long>
|
|
776 |
+ </locale>
|
|
777 |
+ </schema>
|
|
778 |
+
|
|
779 |
+ <schema>
|
|
780 |
+ <key>/schemas/apps/gnome-power-manager/cpufreq/policy_battery</key>
|
|
781 |
+ <applyto>/apps/gnome-power-manager/cpufreq/policy_battery</applyto>
|
|
782 |
+ <owner>gnome-power-manager</owner>
|
|
783 |
+ <type>string</type>
|
|
784 |
+ <default>nothing</default>
|
|
785 |
+ <locale name="C">
|
|
786 |
+ <short>The cpufreq policy to use when on battery power</short>
|
|
787 |
+ <long>The cpufreq policy used to scale the processor when on battery power. Possible values are ondemand, conservative, powersave, userspace, performance, nothing.</long>
|
|
788 |
+ </locale>
|
|
789 |
+ </schema>
|
|
790 |
+
|
|
791 |
+ <schema>
|
|
792 |
+ <key>/schemas/apps/gnome-power-manager/cpufreq/performance_battery</key>
|
|
793 |
+ <applyto>/apps/gnome-power-manager/cpufreq/performance_battery</applyto>
|
|
794 |
+ <owner>gnome-power-manager</owner>
|
|
795 |
+ <type>int</type>
|
|
796 |
+ <default>25</default>
|
|
797 |
+ <locale name="C">
|
|
798 |
+ <short>The cpufreq performance value to use when on battery power</short>
|
|
799 |
+ <long>The cpufreq performance value used to scale the processor when on battery power.</long>
|
|
800 |
+ </locale>
|
|
801 |
+ </schema>
|
|
802 |
+
|
|
803 |
+ <schema>
|
|
804 |
<key>/schemas/apps/gnome-power-manager/general/installed_schema</key>
|
|
805 |
<applyto>/apps/gnome-power-manager/general/installed_schema</applyto>
|
|
806 |
<owner>gnome-power-manager</owner>
|
|
807 |
--- data/gpm-prefs.glade.orig 2008-09-16 12:10:25.562141000 +0800
|
|
808 |
+++ data/gpm-prefs.glade 2008-09-16 12:20:00.554400000 +0800
|
|
809 |
@@ -111,6 +111,58 @@
|
|
810 |
<property name="position">1</property>
|
|
811 |
</packing>
|
|
812 |
</child>
|
|
813 |
+
|
|
814 |
+ <child>
|
|
815 |
+ <widget class="GtkHBox" id="hbox_ac_cpu">
|
|
816 |
+ <property name="visible">True</property>
|
|
817 |
+ <property name="homogeneous">True</property>
|
|
818 |
+ <property name="spacing">12</property>
|
|
819 |
+
|
|
820 |
+ <child>
|
|
821 |
+ <widget class="GtkLabel" id="label_ac_cpu">
|
|
822 |
+ <property name="visible">True</property>
|
15181
|
823 |
+ <property name="label" translatable="yes" comments="SUN_BRANDING">Computer sp_eed policy:</property>
|
13603
|
824 |
+ <property name="use_underline">True</property>
|
|
825 |
+ <property name="use_markup">False</property>
|
|
826 |
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
|
|
827 |
+ <property name="wrap">False</property>
|
|
828 |
+ <property name="selectable">False</property>
|
|
829 |
+ <property name="xalign">0</property>
|
|
830 |
+ <property name="yalign">0.5</property>
|
|
831 |
+ <property name="xpad">0</property>
|
|
832 |
+ <property name="ypad">0</property>
|
|
833 |
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
|
834 |
+ <property name="width_chars">-1</property>
|
|
835 |
+ <property name="single_line_mode">False</property>
|
|
836 |
+ <property name="angle">0</property>
|
|
837 |
+ </widget>
|
|
838 |
+ <packing>
|
|
839 |
+ <property name="padding">0</property>
|
|
840 |
+ <property name="expand">False</property>
|
|
841 |
+ <property name="fill">True</property>
|
|
842 |
+ </packing>
|
|
843 |
+ </child>
|
|
844 |
+
|
|
845 |
+ <child>
|
|
846 |
+ <widget class="GtkComboBox" id="combobox_ac_cpu">
|
|
847 |
+ <property name="visible">True</property>
|
|
848 |
+ <property name="items" translatable="yes"></property>
|
|
849 |
+ <property name="add_tearoffs">False</property>
|
|
850 |
+ <property name="focus_on_click">True</property>
|
|
851 |
+ </widget>
|
|
852 |
+ <packing>
|
|
853 |
+ <property name="padding">0</property>
|
|
854 |
+ <property name="expand">True</property>
|
|
855 |
+ <property name="fill">True</property>
|
|
856 |
+ </packing>
|
|
857 |
+ </child>
|
|
858 |
+ </widget>
|
|
859 |
+ <packing>
|
|
860 |
+ <property name="padding">0</property>
|
|
861 |
+ <property name="expand">True</property>
|
|
862 |
+ <property name="fill">True</property>
|
|
863 |
+ </packing>
|
|
864 |
+ </child>
|
|
865 |
</widget>
|
|
866 |
</child>
|
|
867 |
</widget>
|
|
868 |
@@ -378,6 +430,58 @@
|
|
869 |
<property name="position">2</property>
|
|
870 |
</packing>
|
|
871 |
</child>
|
|
872 |
+
|
|
873 |
+ <child>
|
|
874 |
+ <widget class="GtkHBox" id="hbox_battery_cpu">
|
|
875 |
+ <property name="visible">True</property>
|
|
876 |
+ <property name="homogeneous">True</property>
|
|
877 |
+ <property name="spacing">12</property>
|
|
878 |
+
|
|
879 |
+ <child>
|
|
880 |
+ <widget class="GtkLabel" id="label_battery_cpu">
|
|
881 |
+ <property name="visible">True</property>
|
15181
|
882 |
+ <property name="label" translatable="yes" comments="SUN_BRANDING">Computer sp_eed policy:</property>
|
13603
|
883 |
+ <property name="use_underline">True</property>
|
|
884 |
+ <property name="use_markup">False</property>
|
|
885 |
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
|
|
886 |
+ <property name="wrap">False</property>
|
|
887 |
+ <property name="selectable">False</property>
|
|
888 |
+ <property name="xalign">0</property>
|
|
889 |
+ <property name="yalign">0.5</property>
|
|
890 |
+ <property name="xpad">0</property>
|
|
891 |
+ <property name="ypad">0</property>
|
|
892 |
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
|
893 |
+ <property name="width_chars">-1</property>
|
|
894 |
+ <property name="single_line_mode">False</property>
|
|
895 |
+ <property name="angle">0</property>
|
|
896 |
+ </widget>
|
|
897 |
+ <packing>
|
|
898 |
+ <property name="padding">0</property>
|
|
899 |
+ <property name="expand">False</property>
|
|
900 |
+ <property name="fill">True</property>
|
|
901 |
+ </packing>
|
|
902 |
+ </child>
|
|
903 |
+
|
|
904 |
+ <child>
|
|
905 |
+ <widget class="GtkComboBox" id="combobox_battery_cpu">
|
|
906 |
+ <property name="visible">True</property>
|
|
907 |
+ <property name="items" translatable="yes"></property>
|
|
908 |
+ <property name="add_tearoffs">False</property>
|
|
909 |
+ <property name="focus_on_click">True</property>
|
|
910 |
+ </widget>
|
|
911 |
+ <packing>
|
|
912 |
+ <property name="padding">0</property>
|
|
913 |
+ <property name="expand">True</property>
|
|
914 |
+ <property name="fill">True</property>
|
|
915 |
+ </packing>
|
|
916 |
+ </child>
|
|
917 |
+ </widget>
|
|
918 |
+ <packing>
|
|
919 |
+ <property name="padding">0</property>
|
|
920 |
+ <property name="expand">True</property>
|
|
921 |
+ <property name="fill">True</property>
|
|
922 |
+ </packing>
|
|
923 |
+ </child>
|
|
924 |
</widget>
|
|
925 |
</child>
|
|
926 |
</widget>
|
|
927 |
--- src/Makefile.am.orig 2008-09-16 10:37:34.789458000 +0800
|
|
928 |
+++ src/Makefile.am 2008-09-16 10:41:39.623511000 +0800
|
|
929 |
@@ -38,6 +38,7 @@
|
|
930 |
$(top_builddir)/libhal-glib/libhal-gdevice.la \
|
|
931 |
$(top_builddir)/libhal-glib/libhal-gdevicestore.la \
|
|
932 |
$(top_builddir)/libhal-glib/libhal-gmanager.la \
|
|
933 |
+ $(top_builddir)/libhal-glib/libhal-gcpufreq.la \
|
|
934 |
$(top_builddir)/libhal-glib/libhal-gpower.la
|
|
935 |
|
|
936 |
LOCAL_LIBDBUS_LIBS = \
|
|
937 |
@@ -164,6 +165,8 @@
|
|
938 |
gpm-srv-brightness-kbd.c \
|
|
939 |
gpm-srv-screensaver.h \
|
|
940 |
gpm-srv-screensaver.c \
|
|
941 |
+ gpm-cpufreq.c \
|
|
942 |
+ gpm-cpufreq.h \
|
|
943 |
gpm-conf.h \
|
|
944 |
gpm-conf.c \
|
|
945 |
gpm-idle.h \
|
|
946 |
--- src/gpm-cpufreq.h.orig 1970-01-01 08:00:00.000000000 +0800
|
|
947 |
+++ src/gpm-cpufreq.h 2008-09-16 10:54:00.762524000 +0800
|
|
948 |
@@ -0,0 +1,55 @@
|
|
949 |
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
|
950 |
+ *
|
|
951 |
+ * Copyright (C) 2006-2007 Richard Hughes <[email protected]>
|
|
952 |
+ *
|
|
953 |
+ * Licensed under the GNU General Public License Version 2
|
|
954 |
+ *
|
|
955 |
+ * This program is free software; you can redistribute it and/or modify
|
|
956 |
+ * it under the terms of the GNU General Public License as published by
|
|
957 |
+ * the Free Software Foundation; either version 2 of the License, or
|
|
958 |
+ * (at your option) any later version.
|
|
959 |
+ *
|
|
960 |
+ * This program is distributed in the hope that it will be useful,
|
|
961 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
962 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
963 |
+ * GNU General Public License for more details.
|
|
964 |
+ *
|
|
965 |
+ * You should have received a copy of the GNU General Public License
|
|
966 |
+ * along with this program; if not, write to the Free Software
|
|
967 |
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
968 |
+ */
|
|
969 |
+
|
|
970 |
+#ifndef __GPMCPUFREQ_H
|
|
971 |
+#define __GPMCPUFREQ_H
|
|
972 |
+
|
|
973 |
+#include <glib-object.h>
|
|
974 |
+
|
|
975 |
+G_BEGIN_DECLS
|
|
976 |
+
|
|
977 |
+#define GPM_TYPE_CPUFREQ (gpm_cpufreq_get_type ())
|
|
978 |
+#define GPM_CPUFREQ(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GPM_TYPE_CPUFREQ, GpmCpufreq))
|
|
979 |
+#define GPM_CPUFREQ_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GPM_TYPE_CPUFREQ, GpmCpufreqClass))
|
|
980 |
+#define GPM_IS_CPUFREQ(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GPM_TYPE_CPUFREQ))
|
|
981 |
+#define GPM_IS_CPUFREQ_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GPM_TYPE_CPUFREQ))
|
|
982 |
+#define GPM_CPUFREQ_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GPM_TYPE_CPUFREQ, GpmCpufreqClass))
|
|
983 |
+
|
|
984 |
+typedef struct GpmCpufreqPrivate GpmCpufreqPrivate;
|
|
985 |
+
|
|
986 |
+typedef struct
|
|
987 |
+{
|
|
988 |
+ GObject parent;
|
|
989 |
+ GpmCpufreqPrivate *priv;
|
|
990 |
+} GpmCpufreq;
|
|
991 |
+
|
|
992 |
+typedef struct
|
|
993 |
+{
|
|
994 |
+ GObjectClass parent_class;
|
|
995 |
+} GpmCpufreqClass;
|
|
996 |
+
|
|
997 |
+GType gpm_cpufreq_get_type (void);
|
|
998 |
+GpmCpufreq *gpm_cpufreq_new (void);
|
|
999 |
+
|
|
1000 |
+G_END_DECLS
|
|
1001 |
+
|
|
1002 |
+#endif /* __GPMCPUFREQ_H */
|
|
1003 |
+
|
|
1004 |
--- src/gpm-cpufreq.c.orig 1970-01-01 08:00:00.000000000 +0800
|
|
1005 |
+++ src/gpm-cpufreq.c 2008-09-16 13:18:02.206211000 +0800
|
|
1006 |
@@ -0,0 +1,250 @@
|
|
1007 |
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
|
|
1008 |
+ *
|
|
1009 |
+ * Copyright (C) 2006-2007 Richard Hughes <[email protected]>
|
|
1010 |
+ *
|
|
1011 |
+ * Licensed under the GNU General Public License Version 2
|
|
1012 |
+ *
|
|
1013 |
+ * This program is free software; you can redistribute it and/or modify
|
|
1014 |
+ * it under the terms of the GNU General Public License as published by
|
|
1015 |
+ * the Free Software Foundation; either version 2 of the License, or
|
|
1016 |
+ * (at your option) any later version.
|
|
1017 |
+ *
|
|
1018 |
+ * This program is distributed in the hope that it will be useful,
|
|
1019 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
1020 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
1021 |
+ * GNU General Public License for more details.
|
|
1022 |
+ *
|
|
1023 |
+ * You should have received a copy of the GNU General Public License
|
|
1024 |
+ * along with this program; if not, write to the Free Software
|
|
1025 |
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
1026 |
+ */
|
|
1027 |
+
|
|
1028 |
+#ifdef HAVE_CONFIG_H
|
|
1029 |
+# include <config.h>
|
|
1030 |
+#endif
|
|
1031 |
+
|
|
1032 |
+#include <string.h>
|
|
1033 |
+#include <glib.h>
|
|
1034 |
+#include <dbus/dbus-glib.h>
|
|
1035 |
+#include <glib/gi18n.h>
|
|
1036 |
+
|
|
1037 |
+#include <libhal-gcpufreq.h>
|
|
1038 |
+
|
|
1039 |
+#include "gpm-ac-adapter.h"
|
|
1040 |
+#include "gpm-conf.h"
|
13729
|
1041 |
+#include "egg-debug.h"
|
13603
|
1042 |
+#include "gpm-cpufreq.h"
|
|
1043 |
+
|
|
1044 |
+static void gpm_cpufreq_class_init (GpmCpufreqClass *klass);
|
|
1045 |
+static void gpm_cpufreq_init (GpmCpufreq *hal);
|
|
1046 |
+static void gpm_cpufreq_finalize (GObject *object);
|
|
1047 |
+
|
|
1048 |
+#define GPM_CPUFREQ_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPM_TYPE_CPUFREQ, GpmCpufreqPrivate))
|
|
1049 |
+
|
|
1050 |
+struct GpmCpufreqPrivate
|
|
1051 |
+{
|
|
1052 |
+ HalGCpufreq *hal_cpufreq;
|
|
1053 |
+ GpmConf *conf;
|
|
1054 |
+ GpmAcAdapter *ac_adapter;
|
|
1055 |
+};
|
|
1056 |
+
|
|
1057 |
+G_DEFINE_TYPE (GpmCpufreq, gpm_cpufreq, G_TYPE_OBJECT)
|
|
1058 |
+
|
|
1059 |
+#if defined(sun) && defined(__SVR4)
|
|
1060 |
+/**
|
|
1061 |
+ * gpm_cpufreq_sync_policy_from_system_to_gconf:
|
|
1062 |
+ * @cpufreq: This class instance
|
|
1063 |
+ *
|
|
1064 |
+ * Changes the cpufreq policy if AC gconf isn't identical to current system setting.
|
|
1065 |
+ * Note: Because Solaris considers server user apart from laptop user, AC gconf key
|
|
1066 |
+ * isn't per user preference any more. In other words, AC gconf key always
|
|
1067 |
+ * identical to current kernel/system configuration. Therefore, we need to
|
|
1068 |
+ * read setting from kernel/system and store in AC gconf key.
|
|
1069 |
+ **/
|
|
1070 |
+static gboolean
|
|
1071 |
+gpm_cpufreq_sync_policy_from_system_to_gconf (GpmCpufreq *cpufreq)
|
|
1072 |
+{
|
|
1073 |
+ gboolean on_ac;
|
|
1074 |
+ guint cpufreq_performance;
|
|
1075 |
+ gchar *cpufreq_policy;
|
|
1076 |
+ HalGCpufreqType cpufreq_type;
|
|
1077 |
+
|
|
1078 |
+ on_ac = gpm_ac_adapter_is_present (cpufreq->priv->ac_adapter);
|
|
1079 |
+ if (on_ac == TRUE) {
|
|
1080 |
+ /* Store current system governor and performance setting into AC gconf key.
|
|
1081 |
+ * Solaris CPUfreq don't support nice, do nothing for that.
|
|
1082 |
+ */
|
|
1083 |
+ hal_gcpufreq_get_governor (cpufreq->priv->hal_cpufreq, &cpufreq_type);
|
|
1084 |
+ cpufreq_policy = hal_gcpufreq_enum_to_string (cpufreq_type);
|
|
1085 |
+ gpm_conf_set_string (cpufreq->priv->conf, GPM_CONF_CPUFREQ_POLICY_AC, cpufreq_policy);
|
|
1086 |
+ if (hal_gcpufreq_get_performance (cpufreq->priv->hal_cpufreq, &cpufreq_performance)) {
|
|
1087 |
+ gpm_conf_set_uint (cpufreq->priv->conf, GPM_CONF_CPUFREQ_PERFORMANCE_AC, cpufreq_performance);
|
|
1088 |
+ }
|
|
1089 |
+ }
|
|
1090 |
+
|
|
1091 |
+ return TRUE;
|
|
1092 |
+}
|
|
1093 |
+#endif
|
|
1094 |
+
|
|
1095 |
+/**
|
|
1096 |
+ * gpm_cpufreq_sync_policy:
|
|
1097 |
+ * @cpufreq: This class instance
|
|
1098 |
+ * @on_ac: If we are on AC power
|
|
1099 |
+ *
|
|
1100 |
+ * Changes the cpufreq policy if required
|
|
1101 |
+ **/
|
|
1102 |
+static gboolean
|
|
1103 |
+gpm_cpufreq_sync_policy (GpmCpufreq *cpufreq)
|
|
1104 |
+{
|
|
1105 |
+ gboolean cpufreq_consider_nice;
|
|
1106 |
+ gboolean on_ac;
|
|
1107 |
+ guint cpufreq_performance;
|
|
1108 |
+ gchar *cpufreq_policy;
|
|
1109 |
+ HalGCpufreqType cpufreq_type;
|
|
1110 |
+
|
|
1111 |
+ on_ac = gpm_ac_adapter_is_present (cpufreq->priv->ac_adapter);
|
|
1112 |
+
|
|
1113 |
+ if (on_ac == TRUE) {
|
|
1114 |
+ gpm_conf_get_bool (cpufreq->priv->conf, GPM_CONF_CPUFREQ_USE_NICE, &cpufreq_consider_nice);
|
|
1115 |
+ gpm_conf_get_string (cpufreq->priv->conf, GPM_CONF_CPUFREQ_POLICY_AC, &cpufreq_policy);
|
|
1116 |
+ gpm_conf_get_uint (cpufreq->priv->conf, GPM_CONF_CPUFREQ_PERFORMANCE_AC, &cpufreq_performance);
|
|
1117 |
+ } else {
|
|
1118 |
+ gpm_conf_get_bool (cpufreq->priv->conf, GPM_CONF_CPUFREQ_USE_NICE, &cpufreq_consider_nice);
|
|
1119 |
+ gpm_conf_get_string (cpufreq->priv->conf, GPM_CONF_CPUFREQ_POLICY_BATT, &cpufreq_policy);
|
|
1120 |
+ gpm_conf_get_uint (cpufreq->priv->conf, GPM_CONF_CPUFREQ_PERFORMANCE_BATT, &cpufreq_performance);
|
|
1121 |
+ }
|
|
1122 |
+
|
|
1123 |
+ /* use enumerated value */
|
|
1124 |
+ cpufreq_type = hal_gcpufreq_string_to_enum (cpufreq_policy);
|
|
1125 |
+ g_free (cpufreq_policy);
|
|
1126 |
+
|
|
1127 |
+ /* change to the right governer and settings */
|
|
1128 |
+ hal_gcpufreq_set_governor (cpufreq->priv->hal_cpufreq, cpufreq_type);
|
|
1129 |
+ hal_gcpufreq_set_consider_nice (cpufreq->priv->hal_cpufreq, cpufreq_consider_nice);
|
|
1130 |
+ // Fix for bugster #6727770. hal_gcpufreq_set_performance (cpufreq->priv->hal_cpufreq, cpufreq_performance);
|
|
1131 |
+ return TRUE;
|
|
1132 |
+}
|
|
1133 |
+
|
|
1134 |
+/**
|
|
1135 |
+ * conf_key_changed_cb:
|
|
1136 |
+ *
|
|
1137 |
+ * We might have to do things when the gconf keys change; do them here.
|
|
1138 |
+ **/
|
|
1139 |
+static void
|
|
1140 |
+conf_key_changed_cb (GpmConf *conf,
|
|
1141 |
+ const gchar *key,
|
|
1142 |
+ GpmCpufreq *cpufreq)
|
|
1143 |
+{
|
|
1144 |
+ /* if any change, just resync the whole lot */
|
|
1145 |
+ if (strcmp (key, GPM_CONF_CPUFREQ_POLICY_AC) == 0 ||
|
|
1146 |
+ strcmp (key, GPM_CONF_CPUFREQ_PERFORMANCE_AC) == 0 ||
|
|
1147 |
+ strcmp (key, GPM_CONF_CPUFREQ_POLICY_BATT) == 0 ||
|
|
1148 |
+ strcmp (key, GPM_CONF_CPUFREQ_PERFORMANCE_BATT) == 0 ||
|
|
1149 |
+ strcmp (key, GPM_CONF_CPUFREQ_USE_NICE) == 0) {
|
|
1150 |
+
|
|
1151 |
+ gpm_cpufreq_sync_policy (cpufreq);
|
|
1152 |
+ }
|
|
1153 |
+}
|
|
1154 |
+
|
|
1155 |
+/**
|
|
1156 |
+ * ac_adapter_changed_cb:
|
|
1157 |
+ * @ac_adapter: The ac_adapter class instance
|
|
1158 |
+ * @on_ac: if we are on AC power
|
|
1159 |
+ * @cpufreq: This class instance
|
|
1160 |
+ *
|
|
1161 |
+ * Does the actions when the ac power source is inserted/removed.
|
|
1162 |
+ **/
|
|
1163 |
+static void
|
|
1164 |
+ac_adapter_changed_cb (GpmAcAdapter *ac_adapter,
|
|
1165 |
+ gboolean on_ac,
|
|
1166 |
+ GpmCpufreq *cpufreq)
|
|
1167 |
+{
|
|
1168 |
+ gpm_cpufreq_sync_policy (cpufreq);
|
|
1169 |
+}
|
|
1170 |
+
|
|
1171 |
+/**
|
|
1172 |
+ * gpm_cpufreq_class_init:
|
|
1173 |
+ * @klass: This class instance
|
|
1174 |
+ **/
|
|
1175 |
+static void
|
|
1176 |
+gpm_cpufreq_class_init (GpmCpufreqClass *klass)
|
|
1177 |
+{
|
|
1178 |
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
1179 |
+ object_class->finalize = gpm_cpufreq_finalize;
|
|
1180 |
+ g_type_class_add_private (klass, sizeof (GpmCpufreqPrivate));
|
|
1181 |
+}
|
|
1182 |
+
|
|
1183 |
+/**
|
|
1184 |
+ * gpm_cpufreq_init:
|
|
1185 |
+ *
|
|
1186 |
+ * @cpufreq: This class instance
|
|
1187 |
+ **/
|
|
1188 |
+static void
|
|
1189 |
+gpm_cpufreq_init (GpmCpufreq *cpufreq)
|
|
1190 |
+{
|
|
1191 |
+ cpufreq->priv = GPM_CPUFREQ_GET_PRIVATE (cpufreq);
|
|
1192 |
+
|
|
1193 |
+ /* we use cpufreq as the master class */
|
|
1194 |
+ cpufreq->priv->hal_cpufreq = hal_gcpufreq_new ();
|
|
1195 |
+
|
|
1196 |
+ /* get changes from gconf */
|
|
1197 |
+ cpufreq->priv->conf = gpm_conf_new ();
|
|
1198 |
+ g_signal_connect (cpufreq->priv->conf, "value-changed",
|
|
1199 |
+ G_CALLBACK (conf_key_changed_cb), cpufreq);
|
|
1200 |
+
|
|
1201 |
+ /* we use ac_adapter for the ac-adapter-changed signal */
|
|
1202 |
+ cpufreq->priv->ac_adapter = gpm_ac_adapter_new ();
|
|
1203 |
+ g_signal_connect (cpufreq->priv->ac_adapter, "ac-adapter-changed",
|
|
1204 |
+ G_CALLBACK (ac_adapter_changed_cb), cpufreq);
|
|
1205 |
+
|
|
1206 |
+ /* sync policy */
|
|
1207 |
+#if defined(sun) && defined(__SVR4)
|
|
1208 |
+ gpm_cpufreq_sync_policy_from_system_to_gconf (cpufreq);
|
|
1209 |
+#else
|
|
1210 |
+ gpm_cpufreq_sync_policy (cpufreq);
|
|
1211 |
+#endif
|
|
1212 |
+}
|
|
1213 |
+
|
|
1214 |
+/**
|
|
1215 |
+ * gpm_cpufreq_finalize:
|
|
1216 |
+ * @object: This class instance
|
|
1217 |
+ **/
|
|
1218 |
+static void
|
|
1219 |
+gpm_cpufreq_finalize (GObject *object)
|
|
1220 |
+{
|
|
1221 |
+ GpmCpufreq *cpufreq;
|
|
1222 |
+ g_return_if_fail (object != NULL);
|
|
1223 |
+ g_return_if_fail (GPM_IS_CPUFREQ (object));
|
|
1224 |
+
|
|
1225 |
+ cpufreq = GPM_CPUFREQ (object);
|
|
1226 |
+ cpufreq->priv = GPM_CPUFREQ_GET_PRIVATE (cpufreq);
|
|
1227 |
+
|
|
1228 |
+ if (cpufreq->priv->hal_cpufreq != NULL) {
|
|
1229 |
+ g_object_unref (cpufreq->priv->hal_cpufreq);
|
|
1230 |
+ }
|
|
1231 |
+ if (cpufreq->priv->conf != NULL) {
|
|
1232 |
+ g_object_unref (cpufreq->priv->conf);
|
|
1233 |
+ }
|
|
1234 |
+ if (cpufreq->priv->ac_adapter != NULL) {
|
|
1235 |
+ g_object_unref (cpufreq->priv->ac_adapter);
|
|
1236 |
+ }
|
|
1237 |
+ G_OBJECT_CLASS (gpm_cpufreq_parent_class)->finalize (object);
|
|
1238 |
+}
|
|
1239 |
+
|
|
1240 |
+/**
|
|
1241 |
+ * gpm_cpufreq_new:
|
|
1242 |
+ * Return value: new GpmCpufreq instance.
|
|
1243 |
+ **/
|
|
1244 |
+GpmCpufreq *
|
|
1245 |
+gpm_cpufreq_new (void)
|
|
1246 |
+{
|
|
1247 |
+ GpmCpufreq *cpufreq = NULL;
|
|
1248 |
+
|
|
1249 |
+ /* only load if we have the hardware */
|
|
1250 |
+ if (hal_gcpufreq_has_hw() == TRUE) {
|
|
1251 |
+ cpufreq = g_object_new (GPM_TYPE_CPUFREQ, NULL);
|
|
1252 |
+ }
|
|
1253 |
+
|
|
1254 |
+ return cpufreq;
|
|
1255 |
+}
|
|
1256 |
+
|
|
1257 |
--- src/gpm-conf.h.orig 2008-09-16 10:56:10.738304000 +0800
|
|
1258 |
+++ src/gpm-conf.h 2008-09-16 10:56:30.989120000 +0800
|
|
1259 |
@@ -72,6 +72,13 @@
|
|
1260 |
#define GPM_CONF_BUTTON_HIBERNATE GPM_CONF_DIR "/buttons/hibernate"
|
|
1261 |
#define GPM_CONF_BUTTON_POWER GPM_CONF_DIR "/buttons/power"
|
|
1262 |
|
|
1263 |
+/* cpufreq */
|
|
1264 |
+#define GPM_CONF_CPUFREQ_POLICY_AC GPM_CONF_DIR "/cpufreq/policy_ac"
|
|
1265 |
+#define GPM_CONF_CPUFREQ_POLICY_BATT GPM_CONF_DIR "/cpufreq/policy_battery"
|
|
1266 |
+#define GPM_CONF_CPUFREQ_PERFORMANCE_AC GPM_CONF_DIR "/cpufreq/performance_ac"
|
|
1267 |
+#define GPM_CONF_CPUFREQ_PERFORMANCE_BATT GPM_CONF_DIR "/cpufreq/performance_battery"
|
|
1268 |
+#define GPM_CONF_CPUFREQ_USE_NICE GPM_CONF_DIR "/cpufreq/consider_nice"
|
|
1269 |
+
|
|
1270 |
/* general */
|
|
1271 |
#define GPM_CONF_DEBUG GPM_CONF_DIR "/general/debug"
|
|
1272 |
#define GPM_CONF_SCHEMA_VERSION GPM_CONF_DIR "/general/installed_schema"
|
|
1273 |
--- src/gpm-prefs-core.c.orig 2008-09-16 11:14:29.546125000 +0800
|
|
1274 |
+++ src/gpm-prefs-core.c 2008-09-16 13:08:23.567034000 +0800
|
|
1275 |
@@ -34,6 +34,7 @@
|
|
1276 |
#include <gconf/gconf-client.h>
|
|
1277 |
|
|
1278 |
#include <libhal-gmanager.h>
|
|
1279 |
+#include <libhal-gcpufreq.h>
|
|
1280 |
|
|
1281 |
#include "gpm-tray-icon.h"
|
|
1282 |
#include "gpm-common.h"
|
|
1283 |
@@ -79,6 +80,8 @@
|
|
1284 |
#ifdef HAVE_GCONF_DEFAULTS
|
|
1285 |
PolKitGnomeAction *default_action;
|
|
1286 |
#endif
|
|
1287 |
+ HalGCpufreq *hal_cpufreq;
|
|
1288 |
+ HalGCpufreqType cpufreq_types;
|
|
1289 |
};
|
|
1290 |
|
|
1291 |
enum {
|
15181
|
1292 |
@@ -99,6 +102,17 @@
|
13603
|
1293 |
#define ACTION_BLANK_TEXT _("Blank screen")
|
|
1294 |
#define ACTION_NOTHING_TEXT _("Do nothing")
|
|
1295 |
|
|
1296 |
+/* The text that should appear in the processor combo box */
|
|
1297 |
+#define CPUFREQ_NOTHING_TEXT _("Do nothing")
|
15181
|
1298 |
+/* SUN_BRANDING */
|
13603
|
1299 |
+#define CPUFREQ_ONDEMAND_TEXT _("Based on processor load")
|
15181
|
1300 |
+/* SUN_BRANDING */
|
13603
|
1301 |
+#define CPUFREQ_CONSERVATIVE_TEXT _("Automatic power saving")
|
15181
|
1302 |
+/* SUN_BRANDING */
|
13603
|
1303 |
+#define CPUFREQ_POWERSAVE_TEXT _("Maximum power saving")
|
15181
|
1304 |
+/* SUN_BRANDING */
|
13603
|
1305 |
+#define CPUFREQ_PERFORMANCE_TEXT _("Always maximum speed")
|
|
1306 |
+
|
|
1307 |
/* If sleep time in a slider is set to 61 it is considered as never */
|
|
1308 |
const int NEVER_TIME_ON_SLIDER = 61;
|
|
1309 |
|
15181
|
1310 |
@@ -704,6 +718,134 @@
|
13603
|
1311 |
}
|
|
1312 |
}
|
|
1313 |
|
|
1314 |
+/**
|
|
1315 |
+ * gpm_prefs_processor_combo_changed_cb:
|
|
1316 |
+ * @widget: The GtkWidget object
|
|
1317 |
+ * @gpm_pref_key: The GConf key for this preference setting.
|
|
1318 |
+ **/
|
|
1319 |
+static void
|
|
1320 |
+gpm_prefs_processor_combo_changed_cb (GtkWidget *widget,
|
|
1321 |
+ GpmPrefs *prefs)
|
|
1322 |
+{
|
|
1323 |
+ gchar *value;
|
|
1324 |
+ const gchar *policy;
|
|
1325 |
+ gchar *gpm_pref_key;
|
|
1326 |
+
|
|
1327 |
+ value = gtk_combo_box_get_active_text (GTK_COMBO_BOX (widget));
|
|
1328 |
+ if (value == NULL) {
|
13729
|
1329 |
+ egg_warning ("active text failed");
|
13603
|
1330 |
+ return;
|
|
1331 |
+ }
|
|
1332 |
+ if (strcmp (value, CPUFREQ_ONDEMAND_TEXT) == 0) {
|
|
1333 |
+ policy = CODE_CPUFREQ_ONDEMAND;
|
|
1334 |
+ } else if (strcmp (value, CPUFREQ_CONSERVATIVE_TEXT) == 0) {
|
|
1335 |
+ policy = CODE_CPUFREQ_CONSERVATIVE;
|
|
1336 |
+ } else if (strcmp (value, CPUFREQ_POWERSAVE_TEXT) == 0) {
|
|
1337 |
+ policy = CODE_CPUFREQ_POWERSAVE;
|
|
1338 |
+ } else if (strcmp (value, CPUFREQ_PERFORMANCE_TEXT) == 0) {
|
|
1339 |
+ policy = CODE_CPUFREQ_PERFORMANCE;
|
|
1340 |
+ } else if (strcmp (value, CPUFREQ_NOTHING_TEXT) == 0) {
|
|
1341 |
+ policy = CODE_CPUFREQ_NOTHING;
|
|
1342 |
+ } else {
|
|
1343 |
+ g_assert (FALSE);
|
|
1344 |
+ }
|
|
1345 |
+
|
|
1346 |
+ g_free (value);
|
|
1347 |
+ gpm_pref_key = (char *) g_object_get_data (G_OBJECT (widget), "conf_key");
|
13729
|
1348 |
+ egg_debug ("Changing %s to %s", gpm_pref_key, policy);
|
13603
|
1349 |
+ gpm_conf_set_string (prefs->priv->conf, gpm_pref_key, policy);
|
|
1350 |
+}
|
|
1351 |
+
|
|
1352 |
+/**
|
|
1353 |
+ * gpm_prefs_setup_action_combo:
|
|
1354 |
+ * @prefs: This prefs class instance
|
|
1355 |
+ * @widget_name: The GtkWidget name
|
|
1356 |
+ * @gpm_pref_key: The GConf key for this preference setting.
|
|
1357 |
+ * @actions: The actions to associate in an array.
|
|
1358 |
+ **/
|
|
1359 |
+static void
|
|
1360 |
+gpm_prefs_setup_processor_combo (GpmPrefs *prefs,
|
|
1361 |
+ const gchar *widget_name,
|
|
1362 |
+ const gchar *gpm_pref_key,
|
|
1363 |
+ HalGCpufreqType cpufreq_types)
|
|
1364 |
+{
|
|
1365 |
+ gchar *value;
|
|
1366 |
+ guint n_added = 0;
|
|
1367 |
+ gboolean has_option = FALSE;
|
|
1368 |
+ gboolean is_writable;
|
|
1369 |
+ GtkWidget *widget;
|
|
1370 |
+ HalGCpufreqType cpufreq_type;
|
|
1371 |
+
|
|
1372 |
+ widget = glade_xml_get_widget (prefs->priv->glade_xml, widget_name);
|
|
1373 |
+ gpm_conf_get_string (prefs->priv->conf, gpm_pref_key, &value);
|
|
1374 |
+ gpm_conf_is_writable (prefs->priv->conf, gpm_pref_key, &is_writable);
|
|
1375 |
+
|
|
1376 |
+ gtk_widget_set_sensitive (widget, is_writable);
|
|
1377 |
+
|
|
1378 |
+ if (value == NULL) {
|
13729
|
1379 |
+ egg_warning ("invalid schema, please re-install");
|
13603
|
1380 |
+ value = g_strdup ("nothing");
|
|
1381 |
+ }
|
|
1382 |
+
|
|
1383 |
+ g_object_set_data (G_OBJECT (widget), "conf_key", (gpointer) gpm_pref_key);
|
|
1384 |
+ g_signal_connect (G_OBJECT (widget), "changed",
|
|
1385 |
+ G_CALLBACK (gpm_prefs_processor_combo_changed_cb),
|
|
1386 |
+ prefs);
|
|
1387 |
+
|
|
1388 |
+ cpufreq_type = hal_gcpufreq_string_to_enum (value);
|
|
1389 |
+
|
|
1390 |
+ if (cpufreq_types & LIBHAL_CPUFREQ_ONDEMAND) {
|
|
1391 |
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget),
|
|
1392 |
+ CPUFREQ_ONDEMAND_TEXT);
|
|
1393 |
+ if (cpufreq_type == LIBHAL_CPUFREQ_ONDEMAND) {
|
|
1394 |
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), n_added);
|
|
1395 |
+ has_option = TRUE;
|
|
1396 |
+ }
|
|
1397 |
+ n_added++;
|
|
1398 |
+ }
|
|
1399 |
+ if (cpufreq_types & LIBHAL_CPUFREQ_NOTHING) {
|
|
1400 |
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget),
|
|
1401 |
+ CPUFREQ_NOTHING_TEXT);
|
|
1402 |
+ if (cpufreq_type == LIBHAL_CPUFREQ_ONDEMAND) {
|
|
1403 |
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), n_added);
|
|
1404 |
+ has_option = TRUE;
|
|
1405 |
+ }
|
|
1406 |
+ n_added++;
|
|
1407 |
+ }
|
|
1408 |
+ if (cpufreq_types & LIBHAL_CPUFREQ_CONSERVATIVE) {
|
|
1409 |
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget),
|
|
1410 |
+ CPUFREQ_CONSERVATIVE_TEXT);
|
|
1411 |
+ if (cpufreq_type == LIBHAL_CPUFREQ_CONSERVATIVE) {
|
|
1412 |
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), n_added);
|
|
1413 |
+ has_option = TRUE;
|
|
1414 |
+ }
|
|
1415 |
+ n_added++;
|
|
1416 |
+ }
|
|
1417 |
+ if (cpufreq_types & LIBHAL_CPUFREQ_POWERSAVE) {
|
|
1418 |
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget),
|
|
1419 |
+ CPUFREQ_POWERSAVE_TEXT);
|
|
1420 |
+ if (cpufreq_type == LIBHAL_CPUFREQ_POWERSAVE) {
|
|
1421 |
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), n_added);
|
|
1422 |
+ has_option = TRUE;
|
|
1423 |
+ }
|
|
1424 |
+ n_added++;
|
|
1425 |
+ }
|
|
1426 |
+ if (cpufreq_types & LIBHAL_CPUFREQ_PERFORMANCE) {
|
|
1427 |
+ gtk_combo_box_append_text (GTK_COMBO_BOX (widget),
|
|
1428 |
+ CPUFREQ_PERFORMANCE_TEXT);
|
|
1429 |
+ if (cpufreq_type == LIBHAL_CPUFREQ_PERFORMANCE) {
|
|
1430 |
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), n_added);
|
|
1431 |
+ has_option = TRUE;
|
|
1432 |
+ }
|
|
1433 |
+ n_added++;
|
|
1434 |
+ }
|
|
1435 |
+
|
|
1436 |
+ if (has_option == FALSE || cpufreq_type == LIBHAL_CPUFREQ_NOTHING) {
|
|
1437 |
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), n_added);
|
|
1438 |
+ }
|
|
1439 |
+ g_free (value);
|
|
1440 |
+}
|
|
1441 |
+
|
|
1442 |
/** setup the notification page */
|
|
1443 |
static void
|
|
1444 |
prefs_setup_notification (GpmPrefs *prefs)
|
15181
|
1445 |
@@ -815,6 +957,7 @@
|
13603
|
1446 |
gint page;
|
|
1447 |
|
|
1448 |
if ((prefs->priv->has_button_lid == FALSE)
|
|
1449 |
+ && (prefs->priv->hal_cpufreq == FALSE)
|
|
1450 |
&& (prefs->priv->has_lcd == FALSE)) {
|
|
1451 |
notebook = glade_xml_get_widget (prefs->priv->glade_xml, "notebook_preferences");
|
|
1452 |
widget = glade_xml_get_widget (prefs->priv->glade_xml, "vbox_ac");
|
15181
|
1453 |
@@ -827,6 +970,8 @@
|
13603
|
1454 |
gpm_prefs_setup_action_combo (prefs, "combobox_ac_lid",
|
|
1455 |
GPM_CONF_BUTTON_LID_AC,
|
|
1456 |
button_lid_actions);
|
|
1457 |
+ gpm_prefs_setup_processor_combo (prefs, "combobox_ac_cpu",
|
|
1458 |
+ GPM_CONF_CPUFREQ_POLICY_AC, prefs->priv->cpufreq_types);
|
|
1459 |
gpm_prefs_setup_sleep_slider (prefs, "hscale_ac_computer",
|
|
1460 |
GPM_CONF_TIMEOUT_SLEEP_COMPUTER_AC);
|
|
1461 |
gpm_prefs_setup_sleep_slider (prefs, "hscale_ac_display",
|
15181
|
1462 |
@@ -845,6 +990,16 @@
|
13603
|
1463 |
widget = glade_xml_get_widget (prefs->priv->glade_xml, "hbox_ac_lid");
|
|
1464 |
gtk_widget_hide_all (widget);
|
|
1465 |
}
|
|
1466 |
+
|
|
1467 |
+#if defined(sun) && defined(__SVR4)
|
|
1468 |
+ if (prefs->priv->hal_cpufreq == NULL || prefs->priv->can_cpufreq == FALSE ) {
|
|
1469 |
+#else
|
|
1470 |
+ if (prefs->priv->hal_cpufreq == NULL) {
|
|
1471 |
+#endif
|
|
1472 |
+ widget = glade_xml_get_widget (prefs->priv->glade_xml, "hbox_ac_cpu");
|
|
1473 |
+ gtk_widget_hide_all (widget);
|
|
1474 |
+ }
|
|
1475 |
+
|
|
1476 |
#if defined(sun) && defined(__SVR4)
|
|
1477 |
if (prefs->priv->has_lcd == FALSE || prefs->priv->can_brightness == FALSE) {
|
|
1478 |
#else
|
15181
|
1479 |
@@ -1060,6 +1064,8 @@
|
13699
|
1480 |
gpm_prefs_setup_action_combo (prefs, "combobox_battery_critical",
|
|
1481 |
GPM_CONF_ACTIONS_CRITICAL_BATT,
|
|
1482 |
battery_critical_actions);
|
|
1483 |
+ gpm_prefs_setup_processor_combo (prefs, "combobox_battery_cpu",
|
|
1484 |
+ GPM_CONF_CPUFREQ_POLICY_BATT, prefs->priv->cpufreq_types);
|
|
1485 |
gpm_prefs_setup_sleep_slider (prefs, "hscale_battery_computer",
|
|
1486 |
GPM_CONF_TIMEOUT_SLEEP_COMPUTER_BATT);
|
|
1487 |
gpm_prefs_setup_sleep_slider (prefs, "hscale_battery_display",
|
15181
|
1488 |
@@ -1133,6 +1288,8 @@
|
13603
|
1489 |
|
|
1490 |
prefs->priv = GPM_PREFS_GET_PRIVATE (prefs);
|
|
1491 |
|
|
1492 |
+ prefs->priv->hal_cpufreq = hal_gcpufreq_new ();
|
|
1493 |
+
|
|
1494 |
prefs->priv->screensaver = gpm_screensaver_new ();
|
|
1495 |
g_signal_connect (prefs->priv->screensaver, "gs-delay-changed",
|
|
1496 |
G_CALLBACK (gs_delay_changed_cb), prefs);
|
15181
|
1497 |
@@ -1161,6 +1318,7 @@
|
13603
|
1498 |
GpmControl *control = gpm_control_new ();
|
|
1499 |
if (control) {
|
|
1500 |
prefs->priv->can_cpufreq = gpm_control_is_user_privileged (control, "hal-power-cpu");
|
|
1501 |
+ prefs->priv->can_cpufreq = 1;
|
|
1502 |
prefs->priv->can_brightness = gpm_control_is_user_privileged (control, "hal-power-brightness");
|
|
1503 |
g_object_unref (control);
|
|
1504 |
} else {
|
15181
|
1505 |
@@ -1178,6 +1336,14 @@
|
13603
|
1506 |
gpk_prefs_setup_policykit (prefs);
|
|
1507 |
#endif
|
|
1508 |
|
|
1509 |
+ /* only enable cpufreq stuff if we have the hardware */
|
|
1510 |
+ if (prefs->priv->hal_cpufreq) {
|
|
1511 |
+ hal_gcpufreq_get_governors (prefs->priv->hal_cpufreq,
|
|
1512 |
+ &prefs->priv->cpufreq_types);
|
|
1513 |
+ } else {
|
|
1514 |
+ prefs->priv->cpufreq_types = LIBHAL_CPUFREQ_NOTHING;
|
|
1515 |
+ }
|
|
1516 |
+
|
|
1517 |
prefs->priv->glade_xml = glade_xml_new (GPM_DATA "/gpm-prefs.glade", NULL, NULL);
|
|
1518 |
if (prefs->priv->glade_xml == NULL) {
|
|
1519 |
g_error ("Cannot find 'gpm-prefs.glade'");
|
15181
|
1520 |
@@ -1235,6 +1401,10 @@
|
13603
|
1521 |
g_object_unref (prefs->priv->screensaver);
|
|
1522 |
}
|
|
1523 |
|
|
1524 |
+ if (prefs->priv->hal_cpufreq) {
|
|
1525 |
+ g_object_unref (prefs->priv->hal_cpufreq);
|
|
1526 |
+ }
|
|
1527 |
+
|
|
1528 |
G_OBJECT_CLASS (gpm_prefs_parent_class)->finalize (object);
|
|
1529 |
}
|
|
1530 |
|
|
1531 |
--- src/gpm-manager.c.orig 2008-09-16 14:48:55.069459000 +0800
|
|
1532 |
+++ src/gpm-manager.c 2008-09-16 14:58:21.514052000 +0800
|
|
1533 |
@@ -48,6 +48,7 @@
|
|
1534 |
#include "gpm-conf.h"
|
|
1535 |
#include "gpm-control.h"
|
|
1536 |
#include "gpm-common.h"
|
|
1537 |
+#include "gpm-cpufreq.h"
|
13729
|
1538 |
#include "egg-debug.h"
|
13603
|
1539 |
#include "gpm-dpms.h"
|
|
1540 |
#include "gpm-idle.h"
|
|
1541 |
@@ -99,6 +100,7 @@
|
|
1542 |
GpmBacklight *backlight;
|
14694
|
1543 |
EggConsoleKit *console;
|
13603
|
1544 |
GpmSrvBrightnessKbd *srv_brightness_kbd;
|
|
1545 |
+ GpmCpufreq *cpufreq;
|
|
1546 |
GpmSrvScreensaver *srv_screensaver;
|
|
1547 |
};
|
|
1548 |
|
|
1549 |
@@ -1742,6 +1744,8 @@
|
|
1550 |
manager->priv->sound = gpm_sound_new ();
|
|
1551 |
|
|
1552 |
/* try and start an interactive service */
|
|
1553 |
+ manager->priv->cpufreq = gpm_cpufreq_new ();
|
|
1554 |
+
|
|
1555 |
manager->priv->screensaver = gpm_screensaver_new ();
|
|
1556 |
g_signal_connect (manager->priv->screensaver, "auth-request",
|
|
1557 |
G_CALLBACK (screensaver_auth_request_cb), manager);
|