Created
March 13, 2013 17:14
-
-
Save theuni/5154204 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From b4cad5173902e69d125c99e639a6204773b2f52f Mon Sep 17 00:00:00 2001 | |
From: Cory Fields <theuni-nospam-@xbmc.org> | |
Date: Wed, 13 Mar 2013 12:55:52 -0400 | |
Subject: [PATCH] power: Add a bare-metal linux power implementation that | |
relies on being launched by init | |
--- | |
xbmc/powermanagement/PowerManager.cpp | 17 +++++++--- | |
xbmc/powermanagement/linux/FallbackPowerSyscall.h | 41 +++++++++++++++++++++++ | |
2 files changed, 53 insertions(+), 5 deletions(-) | |
create mode 100644 xbmc/powermanagement/linux/FallbackPowerSyscall.h | |
diff --git a/xbmc/powermanagement/PowerManager.cpp b/xbmc/powermanagement/PowerManager.cpp | |
index ca94f49..5d71b36 100644 | |
--- a/xbmc/powermanagement/PowerManager.cpp | |
+++ b/xbmc/powermanagement/PowerManager.cpp | |
@@ -37,12 +37,15 @@ | |
#include "osx/CocoaPowerSyscall.h" | |
#elif defined(TARGET_ANDROID) | |
#include "android/AndroidPowerSyscall.h" | |
-#elif defined(_LINUX) && defined(HAS_DBUS) | |
+#elif defined(TARGET_LINUX) | |
+#include "linux/FallbackPowerSyscall.h" | |
+#if defined(HAS_DBUS) | |
#include "linux/ConsoleUPowerSyscall.h" | |
#include "linux/ConsoleDeviceKitPowerSyscall.h" | |
#include "linux/SystemdUPowerSyscall.h" | |
#include "linux/UPowerSyscall.h" | |
-#ifdef HAS_HAL | |
+#endif | |
+#if defined(HAS_HAL) | |
#include "linux/HALPowerSyscall.h" | |
#endif | |
#elif defined(_WIN32) | |
@@ -70,8 +73,11 @@ void CPowerManager::Initialize() | |
m_instance = new CCocoaPowerSyscall(); | |
#elif defined(TARGET_ANDROID) | |
m_instance = new CAndroidPowerSyscall(); | |
-#elif defined(_LINUX) && defined(HAS_DBUS) | |
- if (CConsoleUPowerSyscall::HasConsoleKitAndUPower()) | |
+#elif defined(TARGET_LINUX) | |
+ if(1) | |
+ m_instance = new CFallbackPowerSyscall(); | |
+#if defined(HAS_DBUS) | |
+ else if (CConsoleUPowerSyscall::HasConsoleKitAndUPower()) | |
m_instance = new CConsoleUPowerSyscall(); | |
else if (CConsoleDeviceKitPowerSyscall::HasDeviceConsoleKit()) | |
m_instance = new CConsoleDeviceKitPowerSyscall(); | |
@@ -79,7 +85,8 @@ void CPowerManager::Initialize() | |
m_instance = new CSystemdUPowerSyscall(); | |
else if (CUPowerSyscall::HasUPower()) | |
m_instance = new CUPowerSyscall(); | |
-#ifdef HAS_HAL | |
+#endif | |
+#if defined(HAS_HAL) | |
else | |
m_instance = new CHALPowerSyscall(); | |
#endif | |
diff --git a/xbmc/powermanagement/linux/FallbackPowerSyscall.h b/xbmc/powermanagement/linux/FallbackPowerSyscall.h | |
new file mode 100644 | |
index 0000000..1f0f300 | |
--- /dev/null | |
+++ b/xbmc/powermanagement/linux/FallbackPowerSyscall.h | |
@@ -0,0 +1,41 @@ | |
+/* | |
+ * Copyright (C) 2005-2013 Team XBMC | |
+ * http://www.xbmc.org | |
+ * | |
+ * This Program is free software; you can redistribute it and/or modify | |
+ * it under the terms of the GNU General Public License as published by | |
+ * the Free Software Foundation; either version 2, or (at your option) | |
+ * any later version. | |
+ * | |
+ * This Program is distributed in the hope that it will be useful, | |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
+ * GNU General Public License for more details. | |
+ * | |
+ * You should have received a copy of the GNU General Public License | |
+ * along with XBMC; see the file COPYING. If not, see | |
+ * <http://www.gnu.org/licenses/>. | |
+ * | |
+ */ | |
+#pragma once | |
+#include "powermanagement/IPowerSyscall.h" | |
+#include "system.h" | |
+#if defined(TARGET_LINUX) | |
+ | |
+class CFallbackPowerSyscall : public CPowerSyscallWithoutEvents | |
+{ | |
+public: | |
+ CFallbackPowerSyscall(); | |
+ | |
+ virtual bool Powerdown() {return true; } | |
+ virtual bool Suspend() {return false; } | |
+ virtual bool Hibernate() {return false; } | |
+ virtual bool Reboot() {return true; } | |
+ | |
+ virtual bool CanPowerdown() {return true; } | |
+ virtual bool CanSuspend() {return false; } | |
+ virtual bool CanHibernate() {return false; } | |
+ virtual bool CanReboot() {return true; } | |
+ virtual int BatteryLevel() {return 0; } | |
+}; | |
+#endif | |
-- | |
1.8.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment