all: clean up pwrmngr header file

This commit is contained in:
Stefan Seyfried
2013-11-03 00:15:19 +01:00
parent e746daaf5a
commit fc0300416b
17 changed files with 135 additions and 229 deletions

View File

@@ -14,6 +14,5 @@ libazbox_la_SOURCES = \
audio.cpp \
init.cpp \
playback.cpp \
pwrmngr.cpp \
record.cpp

View File

@@ -1 +0,0 @@
../libspark/pwrmngr.cpp

View File

@@ -1 +0,0 @@
../libspark/pwrmngr.h

View File

@@ -8,4 +8,5 @@ AM_CXXFLAGS += \
libcommon_la_SOURCES = \
ca.cpp \
lt_debug.c \
proc_tools.c
proc_tools.c \
pwrmngr.cpp

View File

@@ -1,8 +1,28 @@
#include <stdio.h>
#include <cstdlib>
/*
* (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 <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include "pwrmngr.h"
#include "lt_debug.h"
#if HAVE_TRIPLEDRAGON
#include <stdio.h>
#include <cstdlib>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
@@ -11,32 +31,50 @@
#include <avs/avs_inf.h>
#include <tdpanel/lcdstuff.h>
#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__);
}

View File

@@ -24,6 +24,5 @@ libgeneric_la_SOURCES = \
glfb.cpp \
init.cpp \
playback.cpp \
pwrmngr.cpp \
record.cpp

View File

@@ -1 +0,0 @@
../libspark/pwrmngr.cpp

View File

@@ -1 +0,0 @@
../libspark/pwrmngr.h

View File

@@ -1,16 +1,47 @@
#include <config.h>
#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 <http://www.gnu.org/licenses/>.
*/
#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

View File

@@ -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

View File

@@ -1,74 +0,0 @@
#include <stdio.h>
#include "pwrmngr.h"
#include "lt_debug.h"
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#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__); }

View File

@@ -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__

View File

@@ -17,5 +17,4 @@ libtriple_la_SOURCES = \
audio_td.cpp \
init_td.cpp \
playback_td.cpp \
pwrmngr.cpp \
record_td.cpp

View File

@@ -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__

View File

@@ -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

View File

@@ -1 +0,0 @@
../libspark/pwrmngr.cpp

View File

@@ -1 +0,0 @@
../libspark/pwrmngr.h