libtriple: implement pwrmngr cpufreq classes (mostly dummies)

This commit is contained in:
Stefan Seyfried
2010-08-08 13:27:26 +02:00
parent 7076b238ee
commit 73b886a702
2 changed files with 120 additions and 0 deletions

67
libtriple/pwrmngr.cpp Normal file
View File

@@ -0,0 +1,67 @@
#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>
#include <avs/avs_inf.h>
static const char * FILENAME = "pwrmngr.cpp";
void cCpuFreqManager::Up(void) { lt_debug("%s:%s\n", FILENAME, __FUNCTION__); }
void cCpuFreqManager::Down(void) { lt_debug("%s:%s\n", FILENAME, __FUNCTION__); }
void cCpuFreqManager::Reset(void) { lt_debug("%s:%s\n", FILENAME, __FUNCTION__); }
/* those function dummies return true or "harmless" values */
bool cCpuFreqManager::SetDelta(unsigned long) { lt_debug("%s:%s\n", FILENAME, __FUNCTION__); return true; }
unsigned long cCpuFreqManager::GetCpuFreq(void) { lt_debug("%s:%s\n", FILENAME, __FUNCTION__); return 0; }
unsigned long cCpuFreqManager::GetDelta(void) { lt_debug("%s:%s\n", FILENAME, __FUNCTION__); return 0; }
//
cCpuFreqManager::cCpuFreqManager(void) { lt_debug("%s:%s\n", FILENAME, __FUNCTION__); }
bool cPowerManager::SetState(PWR_STATE) { lt_debug("%s:%s\n", FILENAME, __FUNCTION__); return true; }
bool cPowerManager::Open(void) { lt_debug("%s:%s\n", FILENAME, __FUNCTION__); return true; }
void cPowerManager::Close(void) { lt_debug("%s:%s\n", FILENAME, __FUNCTION__); }
//
bool cPowerManager::SetStandby(bool Active, bool Passive)
{
lt_debug("%s:%s(%d, %d)\n", FILENAME, __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:%s(%lu)\n", FILENAME, __FUNCTION__, f);
int fd = open("/dev/stb/tdsystem", O_RDONLY);
if (fd < 0)
{
perror("open tdsystem");
return false;
}
if (f)
ioctl(fd, IOC_AVS_STANDBY_ENTER);
else
ioctl(fd, IOC_AVS_STANDBY_LEAVE);
close(fd);
return true;
}
//
cPowerManager::cPowerManager(void) { lt_debug("%s:%s\n", FILENAME, __FUNCTION__); }
cPowerManager::~cPowerManager() { lt_debug("%s:%s\n", FILENAME, __FUNCTION__); }

53
libtriple/pwrmngr.h Normal file
View File

@@ -0,0 +1,53 @@
#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__