summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw/tdecpudevice.cpp
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2013-08-12 02:56:12 +0200
committerSlávek Banko <slavek.banko@axis.cz>2013-08-12 03:00:54 +0200
commitf27e71dcb162e37234ea98570379f60f8afdd8ea (patch)
tree20de7b1fa0fd56ceaf043ac791a87d3ad873a49b /tdecore/tdehw/tdecpudevice.cpp
parent3a601abfd441a9416a6cd2d6b0d7ce35d8dd5a21 (diff)
downloadtdelibs-f27e71dcb162e37234ea98570379f60f8afdd8ea.tar.gz
tdelibs-f27e71dcb162e37234ea98570379f60f8afdd8ea.zip
Add HAL power management backend to TDE hardware library
Diffstat (limited to 'tdecore/tdehw/tdecpudevice.cpp')
-rw-r--r--tdecore/tdehw/tdecpudevice.cpp39
1 files changed, 37 insertions, 2 deletions
diff --git a/tdecore/tdehw/tdecpudevice.cpp b/tdecore/tdehw/tdecpudevice.cpp
index e1b5cd4ce..d02cf77f1 100644
--- a/tdecore/tdehw/tdecpudevice.cpp
+++ b/tdecore/tdehw/tdecpudevice.cpp
@@ -30,13 +30,13 @@
#include "config.h"
// uPower
-#if defined(WITH_TDEHWLIB_DAEMONS)
+#if defined(WITH_TDEHWLIB_DAEMONS) || defined(WITH_HAL)
#include <tqdbusdata.h>
#include <tqdbusmessage.h>
#include <tqdbusproxy.h>
#include <tqdbusvariant.h>
#include <tqdbusconnection.h>
-#endif // defined(WITH_TDEHWLIB_DAEMONS)
+#endif // defined(WITH_TDEHWLIB_DAEMONS) || defined(WITH_HAL)
TDECPUDevice::TDECPUDevice(TDEGenericDeviceType::TDEGenericDeviceType dt, TQString dn) : TDEGenericDevice(dt, dn) {
@@ -151,6 +151,23 @@ bool TDECPUDevice::canSetGovernor() {
}
#endif // WITH_TDEHWLIB_DAEMONS
+#ifdef WITH_HAL
+ {
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusMessage msg = TQT_DBusMessage::methodCall(
+ "org.freedesktop.Hal",
+ "/org/freedesktop/Hal/devices/computer",
+ "org.freedesktop.Hal.Device.CPUFreq",
+ "GetCPUFreqGovernor");
+ TQT_DBusMessage reply = dbusConn.sendWithReply(msg);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ return true;
+ }
+ }
+ }
+#endif // WITH_HAL
+
return FALSE;
}
@@ -184,6 +201,24 @@ void TDECPUDevice::setGovernor(TQString gv) {
}
#endif // WITH_TDEHWLIB_DAEMONS
+#ifdef WITH_HAL
+ if ( !setGovernorDone ) {
+ TQT_DBusConnection dbusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus);
+ if (dbusConn.isConnected()) {
+ TQT_DBusProxy cpuFreqControl("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer", "org.freedesktop.Hal.Device.CPUFreq", dbusConn);
+ if (cpuFreqControl.canSend()) {
+ // set CPU governor
+ TQValueList<TQT_DBusData> params;
+ params << TQT_DBusData::fromString(gv.lower());
+ TQT_DBusMessage reply = cpuFreqControl.sendWithReply("SetCPUFreqGovernor", params);
+ if (reply.type() == TQT_DBusMessage::ReplyMessage && reply.count() == 1) {
+ setGovernorDone = TRUE;
+ }
+ }
+ }
+ }
+#endif // WITH_HAL
+
// Force update of the device information object
if ( setGovernorDone ) {
TDEGlobal::hardwareDevices()->processModifiedCPUs();