From fc0300416bd12ee9beb971f205c527c1fcacca4a Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 3 Nov 2013 00:15:19 +0100 Subject: [PATCH] all: clean up pwrmngr header file --- azbox/Makefile.am | 1 - azbox/pwrmngr.cpp | 1 - azbox/pwrmngr.h | 1 - common/Makefile.am | 3 +- {libtriple => common}/pwrmngr.cpp | 109 ++++++++++++++++++++++++------ generic-pc/Makefile.am | 1 - generic-pc/pwrmngr.cpp | 1 - generic-pc/pwrmngr.h | 1 - include/pwrmngr.h | 61 +++++++++++++---- libspark/Makefile.am | 1 - libspark/pwrmngr.cpp | 74 -------------------- libspark/pwrmngr.h | 53 --------------- libtriple/Makefile.am | 1 - libtriple/pwrmngr.h | 53 --------------- raspi/Makefile.am | 1 - raspi/pwrmngr.cpp | 1 - raspi/pwrmngr.h | 1 - 17 files changed, 135 insertions(+), 229 deletions(-) delete mode 120000 azbox/pwrmngr.cpp delete mode 120000 azbox/pwrmngr.h rename {libtriple => common}/pwrmngr.cpp (51%) delete mode 120000 generic-pc/pwrmngr.cpp delete mode 120000 generic-pc/pwrmngr.h delete mode 100644 libspark/pwrmngr.cpp delete mode 100644 libspark/pwrmngr.h delete mode 100644 libtriple/pwrmngr.h delete mode 120000 raspi/pwrmngr.cpp delete mode 120000 raspi/pwrmngr.h diff --git a/azbox/Makefile.am b/azbox/Makefile.am index 37269a0..7e8b5a7 100644 --- a/azbox/Makefile.am +++ b/azbox/Makefile.am @@ -14,6 +14,5 @@ libazbox_la_SOURCES = \ audio.cpp \ init.cpp \ playback.cpp \ - pwrmngr.cpp \ record.cpp diff --git a/azbox/pwrmngr.cpp b/azbox/pwrmngr.cpp deleted file mode 120000 index cee9acb..0000000 --- a/azbox/pwrmngr.cpp +++ /dev/null @@ -1 +0,0 @@ -../libspark/pwrmngr.cpp \ No newline at end of file diff --git a/azbox/pwrmngr.h b/azbox/pwrmngr.h deleted file mode 120000 index e63e97b..0000000 --- a/azbox/pwrmngr.h +++ /dev/null @@ -1 +0,0 @@ -../libspark/pwrmngr.h \ No newline at end of file diff --git a/common/Makefile.am b/common/Makefile.am index db959db..5001eff 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -8,4 +8,5 @@ AM_CXXFLAGS += \ libcommon_la_SOURCES = \ ca.cpp \ lt_debug.c \ - proc_tools.c + proc_tools.c \ + pwrmngr.cpp diff --git a/libtriple/pwrmngr.cpp b/common/pwrmngr.cpp similarity index 51% rename from libtriple/pwrmngr.cpp rename to common/pwrmngr.cpp index e526246..b9e28ab 100644 --- a/libtriple/pwrmngr.cpp +++ b/common/pwrmngr.cpp @@ -1,8 +1,28 @@ -#include -#include +/* + * (C) 2010-2013 Stefan Seyfried + * + * 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 of the License, 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 this program. If not, see . + */ +#include #include "pwrmngr.h" #include "lt_debug.h" + +#if HAVE_TRIPLEDRAGON +#include +#include + #include #include #include @@ -11,32 +31,50 @@ #include #include +#endif #define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_PWRMNGR, this, args) #define lt_info(args...) _lt_info(TRIPLE_DEBUG_PWRMNGR, this, args) -void cCpuFreqManager::Up(void) { lt_debug("%s\n", __FUNCTION__); } -void cCpuFreqManager::Down(void) { lt_debug("%s\n", __FUNCTION__); } -void cCpuFreqManager::Reset(void) { lt_debug("%s\n", __FUNCTION__); } -/* those function dummies return true or "harmless" values */ -bool cCpuFreqManager::SetDelta(unsigned long) { lt_debug("%s\n", __FUNCTION__); return true; } -unsigned long cCpuFreqManager::GetCpuFreq(void) { lt_debug("%s\n", __FUNCTION__); return 0; } -unsigned long cCpuFreqManager::GetDelta(void) { lt_debug("%s\n", __FUNCTION__); return 0; } -// -cCpuFreqManager::cCpuFreqManager(void) { lt_debug("%s\n", __FUNCTION__); } -bool cPowerManager::SetState(PWR_STATE) { lt_debug("%s\n", __FUNCTION__); return true; } - -bool cPowerManager::Open(void) { lt_debug("%s\n", __FUNCTION__); return true; } -void cPowerManager::Close(void) { lt_debug("%s\n", __FUNCTION__); } -// -bool cPowerManager::SetStandby(bool Active, bool Passive) +/* cpufreqmanager */ +void cCpuFreqManager::Up(void) { - lt_debug("%s(%d, %d)\n", __FUNCTION__, Active, Passive); + lt_debug("%s\n", __func__); +} + +void cCpuFreqManager::Down(void) +{ + lt_debug("%s\n", __func__); +} + +void cCpuFreqManager::Reset(void) +{ + lt_debug("%s\n", __func__); +} + +/* those function dummies return true or "harmless" values */ +bool cCpuFreqManager::SetDelta(unsigned long) +{ + lt_debug("%s\n", __func__); return true; } +unsigned long cCpuFreqManager::GetDelta(void) +{ + lt_debug("%s\n", __func__); + return 0; +} + +unsigned long cCpuFreqManager::GetCpuFreq(void) +{ + lt_debug("%s\n", __func__); + return 0; +} + bool cCpuFreqManager::SetCpuFreq(unsigned long f) { + lt_debug("%s(%lu) => set standby = %s\n", __func__, f, f?"true":"false"); +#if HAVE_TRIPLEDRAGON /* actually SetCpuFreq is used to determine if the system is in standby this is an "elegant" hack, because: * during a recording, cpu freq is kept "high", even if the box is sent to standby @@ -47,7 +85,6 @@ bool cCpuFreqManager::SetCpuFreq(unsigned long f) * f == 0 => max => not standby * f == 50000000 => min => standby */ - lt_debug("%s(%lu) => set standby = %s\n", __FUNCTION__, f, f?"true":"false"); int fd = open("/dev/stb/tdsystem", O_RDONLY); if (fd < 0) { @@ -78,10 +115,38 @@ bool cCpuFreqManager::SetCpuFreq(unsigned long f) } close(fd); +#endif return true; } -// -cPowerManager::cPowerManager(void) { lt_debug("%s\n", __FUNCTION__); } -cPowerManager::~cPowerManager() { lt_debug("%s\n", __FUNCTION__); } +cCpuFreqManager::cCpuFreqManager(void) +{ + lt_debug("%s\n", __func__); +} +/* powermanager */ +bool cPowerManager::Open(void) +{ + lt_debug("%s\n", __func__); + return true; +} + +void cPowerManager::Close(void) +{ + lt_debug("%s\n", __func__); +} +bool cPowerManager::SetStandby(bool Active, bool Passive) +{ + lt_debug("%s(%d, %d)\n", __func__, Active, Passive); + return true; +} + +cPowerManager::cPowerManager(void) +{ + lt_debug("%s\n", __func__); +} + +cPowerManager::~cPowerManager() +{ + lt_debug("%s\n", __func__); +} diff --git a/generic-pc/Makefile.am b/generic-pc/Makefile.am index 04988c3..fdb6281 100644 --- a/generic-pc/Makefile.am +++ b/generic-pc/Makefile.am @@ -24,6 +24,5 @@ libgeneric_la_SOURCES = \ glfb.cpp \ init.cpp \ playback.cpp \ - pwrmngr.cpp \ record.cpp diff --git a/generic-pc/pwrmngr.cpp b/generic-pc/pwrmngr.cpp deleted file mode 120000 index cee9acb..0000000 --- a/generic-pc/pwrmngr.cpp +++ /dev/null @@ -1 +0,0 @@ -../libspark/pwrmngr.cpp \ No newline at end of file diff --git a/generic-pc/pwrmngr.h b/generic-pc/pwrmngr.h deleted file mode 120000 index e63e97b..0000000 --- a/generic-pc/pwrmngr.h +++ /dev/null @@ -1 +0,0 @@ -../libspark/pwrmngr.h \ No newline at end of file diff --git a/include/pwrmngr.h b/include/pwrmngr.h index 3b3dcfe..167929a 100644 --- a/include/pwrmngr.h +++ b/include/pwrmngr.h @@ -1,16 +1,47 @@ -#include -#if HAVE_TRIPLEDRAGON -#include "../libtriple/pwrmngr.h" -#elif HAVE_SPARK_HARDWARE -#include "../libspark/pwrmngr.h" -#elif HAVE_AZBOX_HARDWARE -#include "../azbox/pwrmngr.h" -#elif HAVE_GENERIC_HARDWARE -#if BOXMODEL_RASPI -#include "../raspi/pwrmngr.h" -#else -#include "../generic-pc/pwrmngr.h" -#endif -#else -#error neither HAVE_TRIPLEDRAGON nor HAVE_SPARK_HARDWARE defined +/* + * (C) 2010-2013 Stefan Seyfried + * + * 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 of the License, 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 this program. If not, see . + */ + +#ifndef __pwrmngr_hal__ +#define __pwrmngr_hal__ + +class cCpuFreqManager +{ +public: + cCpuFreqManager(void); + void Up(void); + void Down(void); + void Reset(void); + + bool SetCpuFreq(unsigned long CpuFreq); + bool SetDelta(unsigned long Delta); + unsigned long GetCpuFreq(void); + unsigned long GetDelta(void); +}; + +class cPowerManager +{ +public: + cPowerManager(void); + virtual ~cPowerManager(); + + bool Open(void); + void Close(void); + + bool SetStandby(bool Active, bool Passive); +}; + #endif diff --git a/libspark/Makefile.am b/libspark/Makefile.am index 789f61c..891b847 100644 --- a/libspark/Makefile.am +++ b/libspark/Makefile.am @@ -17,7 +17,6 @@ libspark_la_SOURCES = \ audio.cpp \ init.cpp \ playback_libeplayer3.cpp \ - pwrmngr.cpp \ record.cpp AM_CPPFLAGS += -DF_INTERRUPTS=20000 -DIRMP_EMBED -DLIRC_IRMP diff --git a/libspark/pwrmngr.cpp b/libspark/pwrmngr.cpp deleted file mode 100644 index 5b98b7f..0000000 --- a/libspark/pwrmngr.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include - -#include "pwrmngr.h" -#include "lt_debug.h" -#include -#include -#include -#include -#include - -#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_PWRMNGR, this, args) -void cCpuFreqManager::Up(void) { lt_debug("%s\n", __FUNCTION__); } -void cCpuFreqManager::Down(void) { lt_debug("%s\n", __FUNCTION__); } -void cCpuFreqManager::Reset(void) { lt_debug("%s\n", __FUNCTION__); } -/* those function dummies return true or "harmless" values */ -bool cCpuFreqManager::SetDelta(unsigned long) { lt_debug("%s\n", __FUNCTION__); return true; } -unsigned long cCpuFreqManager::GetCpuFreq(void) { lt_debug("%s\n", __FUNCTION__); return 0; } -unsigned long cCpuFreqManager::GetDelta(void) { lt_debug("%s\n", __FUNCTION__); return 0; } -// -cCpuFreqManager::cCpuFreqManager(void) { lt_debug("%s\n", __FUNCTION__); } - -bool cPowerManager::SetState(PWR_STATE) { lt_debug("%s\n", __FUNCTION__); return true; } - -bool cPowerManager::Open(void) { lt_debug("%s\n", __FUNCTION__); return true; } -void cPowerManager::Close(void) { lt_debug("%s\n", __FUNCTION__); } -// -bool cPowerManager::SetStandby(bool Active, bool Passive) -{ - lt_debug("%s(%d, %d)\n", __FUNCTION__, Active, Passive); - return true; -} - -bool cCpuFreqManager::SetCpuFreq(unsigned long f) -{ - /* actually SetCpuFreq is used to determine if the system is in standby - this is an "elegant" hack, because: - * during a recording, cpu freq is kept "high", even if the box is sent to standby - * the "SetStandby" call is made even if a recording is running - On the TD, setting standby disables the frontend, so we must not do it - if a recording is running. - For now, the values in neutrino are hardcoded: - * f == 0 => max => not standby - * f == 50000000 => min => standby - */ - lt_debug("%s(%lu) => set standby = %s\n", __FUNCTION__, f, f?"true":"false"); -#if 0 - int fd = open("/dev/stb/tdsystem", O_RDONLY); - if (fd < 0) - { - perror("open tdsystem"); - return false; - } - if (f) - { - ioctl(fd, IOC_AVS_SET_VOLUME, 31); /* mute AVS to avoid ugly noise */ - ioctl(fd, IOC_AVS_STANDBY_ENTER); - } - else - { - ioctl(fd, IOC_AVS_SET_VOLUME, 31); /* mute AVS to avoid ugly noise */ - ioctl(fd, IOC_AVS_STANDBY_LEAVE); - /* unmute will be done by cAudio::do_mute(). Ugly, but prevents pops */ - // ioctl(fd, IOC_AVS_SET_VOLUME, 0); /* max gain */ - } - - close(fd); -#endif - return true; -} - -// -cPowerManager::cPowerManager(void) { lt_debug("%s\n", __FUNCTION__); } -cPowerManager::~cPowerManager() { lt_debug("%s\n", __FUNCTION__); } - diff --git a/libspark/pwrmngr.h b/libspark/pwrmngr.h deleted file mode 100644 index 55dc984..0000000 --- a/libspark/pwrmngr.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef __PWRMNGR_H__ -#define __PWRMNGR_H__ - -// -- cCpuFreqManager ---------------------------------------------------------- - -class cCpuFreqManager { -private: - unsigned long startCpuFreq; - unsigned long delta; -public: - void Up(void); - void Down(void); - void Reset(void); - // - bool SetCpuFreq(unsigned long CpuFreq); - bool SetDelta(unsigned long Delta); - unsigned long GetCpuFreq(void); - unsigned long GetDelta(void); - // - cCpuFreqManager(void); - -}; - -// -- cPowerManageger ---------------------------------------------------------- - -typedef enum -{ - PWR_INIT = 1, - PWR_FULL_ACTIVE, /* all devices/clocks up */ - PWR_ACTIVE_STANDBY, - PWR_PASSIVE_STANDBY, - PWR_INVALID -} PWR_STATE; - -class cPowerManager { -private: - bool init; - bool opened; - PWR_STATE powerState; - // - static void ApplicationCallback(void *, void *, signed long, void *, void *) {} - bool SetState(PWR_STATE PowerState); -public: - bool Open(void); - void Close(void); - // - bool SetStandby(bool Active, bool Passive); - // - cPowerManager(void); - virtual ~cPowerManager(); -}; - -#endif // __PWRMNGR_H__ diff --git a/libtriple/Makefile.am b/libtriple/Makefile.am index 40f5518..3fd487e 100644 --- a/libtriple/Makefile.am +++ b/libtriple/Makefile.am @@ -17,5 +17,4 @@ libtriple_la_SOURCES = \ audio_td.cpp \ init_td.cpp \ playback_td.cpp \ - pwrmngr.cpp \ record_td.cpp diff --git a/libtriple/pwrmngr.h b/libtriple/pwrmngr.h deleted file mode 100644 index 55dc984..0000000 --- a/libtriple/pwrmngr.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef __PWRMNGR_H__ -#define __PWRMNGR_H__ - -// -- cCpuFreqManager ---------------------------------------------------------- - -class cCpuFreqManager { -private: - unsigned long startCpuFreq; - unsigned long delta; -public: - void Up(void); - void Down(void); - void Reset(void); - // - bool SetCpuFreq(unsigned long CpuFreq); - bool SetDelta(unsigned long Delta); - unsigned long GetCpuFreq(void); - unsigned long GetDelta(void); - // - cCpuFreqManager(void); - -}; - -// -- cPowerManageger ---------------------------------------------------------- - -typedef enum -{ - PWR_INIT = 1, - PWR_FULL_ACTIVE, /* all devices/clocks up */ - PWR_ACTIVE_STANDBY, - PWR_PASSIVE_STANDBY, - PWR_INVALID -} PWR_STATE; - -class cPowerManager { -private: - bool init; - bool opened; - PWR_STATE powerState; - // - static void ApplicationCallback(void *, void *, signed long, void *, void *) {} - bool SetState(PWR_STATE PowerState); -public: - bool Open(void); - void Close(void); - // - bool SetStandby(bool Active, bool Passive); - // - cPowerManager(void); - virtual ~cPowerManager(); -}; - -#endif // __PWRMNGR_H__ diff --git a/raspi/Makefile.am b/raspi/Makefile.am index fb1e9c6..d8763a6 100644 --- a/raspi/Makefile.am +++ b/raspi/Makefile.am @@ -27,7 +27,6 @@ libraspi_la_SOURCES = \ glfb.cpp \ init.cpp \ playback.cpp \ - pwrmngr.cpp \ record.cpp # OMX stuff, from https://github.com/linuxstb/pidvbip diff --git a/raspi/pwrmngr.cpp b/raspi/pwrmngr.cpp deleted file mode 120000 index cee9acb..0000000 --- a/raspi/pwrmngr.cpp +++ /dev/null @@ -1 +0,0 @@ -../libspark/pwrmngr.cpp \ No newline at end of file diff --git a/raspi/pwrmngr.h b/raspi/pwrmngr.h deleted file mode 120000 index e63e97b..0000000 --- a/raspi/pwrmngr.h +++ /dev/null @@ -1 +0,0 @@ -../libspark/pwrmngr.h \ No newline at end of file