Skip to content

Commit

Permalink
Added power management support for the Raspberry Pi. Since it doesn't…
Browse files Browse the repository at this point in the history
… support true standby, we fake it by turning video on or off, and ignoring remote inputs during the standby phase.
  • Loading branch information
macrule authored and popcornmix committed Mar 26, 2016
1 parent 9215fc9 commit 4de8f79
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 0 deletions.
4 changes: 4 additions & 0 deletions xbmc/powermanagement/PowerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@

#if defined(TARGET_DARWIN)
#include "osx/CocoaPowerSyscall.h"
#elif defined(TARGET_RASPBERRY_PI)
#include "linux/RaspberryPIPowerSyscall.h"
#elif defined(TARGET_ANDROID)
#include "android/AndroidPowerSyscall.h"
#elif defined(TARGET_POSIX)
Expand Down Expand Up @@ -76,6 +78,8 @@ void CPowerManager::Initialize()

#if defined(TARGET_DARWIN)
m_instance = new CCocoaPowerSyscall();
#elif defined(TARGET_RASPBERRY_PI)
m_instance = new CRaspberryPIPowerSyscall();
#elif defined(TARGET_ANDROID)
m_instance = new CAndroidPowerSyscall();
#elif defined(TARGET_POSIX)
Expand Down
5 changes: 5 additions & 0 deletions xbmc/powermanagement/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ set(HEADERS ConsoleDeviceKitPowerSyscall.h
LogindUPowerSyscall.h
UPowerSyscall.h)

if(MMAL_FOUND)
list(APPEND SOURCES RaspberryPIPowerSyscall.cpp)
list(APPEND HEADERS RaspberryPIPowerSyscall.h)
endif()

core_add_library(powermanagement_linux)
1 change: 1 addition & 0 deletions xbmc/powermanagement/linux/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
SRCS=ConsoleDeviceKitPowerSyscall.cpp \
ConsoleUPowerSyscall.cpp \
RaspberryPIPowerSyscall.cpp \
UPowerSyscall.cpp \
LogindUPowerSyscall.cpp

Expand Down
38 changes: 38 additions & 0 deletions xbmc/powermanagement/linux/RaspberryPIPowerSyscall.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (C) 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/>.
*
*/

#if defined(TARGET_RASPBERRY_PI)

#include "RaspberryPIPowerSyscall.h"
#include "RBP.h"

bool CRaspberryPIPowerSyscall::VirtualSleep()
{
g_RBP.SuspendVideoOutput();
return true;
}

bool CRaspberryPIPowerSyscall::VirtualWake()
{
g_RBP.ResumeVideoOutput();
return true;
}

#endif
49 changes: 49 additions & 0 deletions xbmc/powermanagement/linux/RaspberryPIPowerSyscall.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#pragma once
/*
* Copyright (C) 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/>.
*
*/

#ifndef _RASPBERRY_PI_POWER_SYSCALL_H_
#define _RASPBERRY_PI_POWER_SYSCALL_H_

#if defined(TARGET_RASPBERRY_PI)
#include "powermanagement/PowerSyscallVirtualSleep.h"

class CRaspberryPIPowerSyscall : public CPowerSyscallVirtualSleep
{
public:
CRaspberryPIPowerSyscall() : CPowerSyscallVirtualSleep() {}
virtual ~CRaspberryPIPowerSyscall() {}

virtual bool Powerdown() { return false; }
virtual bool Hibernate() { return false; }
virtual bool Reboot() { return false; }

virtual bool CanPowerdown() { return false; }
virtual bool CanHibernate() { return false; }
virtual bool CanReboot() { return true; }

virtual int BatteryLevel() { return 0; }

virtual bool VirtualSleep();
virtual bool VirtualWake();
};
#endif // TARGET_RASPBERRY_PI

#endif // _RASPBERRY_PI_POWER_SYSCALL_H_

0 comments on commit 4de8f79

Please sign in to comment.