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