CPUFreq_Userspace Class Reference

Class to control one CPU's frequency by the powersave daemon. More...

#include <cpufreq_interface.h>

Inheritance diagram for CPUFreq_Userspace:

CPUFreq_Interface CPU List of all members.

Public Member Functions

 CPUFreq_Userspace (std::list< int > cpu_cores)
 constructor
 ~CPUFreq_Userspace ()
 destructor
bool init ()
 init cpufreq interface and set userspace governor

Private Member Functions

bool getMinMaxSpeeds (unsigned long *min, unsigned long *max)
 get the minimum and maximum available speeds
unsigned getSpeed ()
 get the current CPU speed
int increaseSpeed ()
 set speed to the next higher supported value
int decreaseSpeed ()
 set speed to the next lower supported value
bool setSpeed (unsigned kHz)
 set the current CPU speed
void setSpeed (unsigned current, unsigned target)
 set the speed smoothly in steps
void createHysteresisArray ()
 creates the hysteresis array
bool readFrequencies ()
 reads out frequencies
int adjustSpeed ()
 adjusts speeds
void reinitSpeed ()
 reinits speeds
int initFreqsViaFile ()
 inits the available speeds via reading from file
int initFreqsViaTesting ()
 inits the available speeds via testing
void setConfig ()
 set configuration in initialize values

Private Attributes

string CURRENT_SPEED_FILE
 speed file to get or set current speed
unsigned _speeds_kHz [MAX_SPEEDS+1]
 array containing available speeds
unsigned _demotion [MAX_SPEEDS+1]
 demotion
unsigned _current_speed
 the current set speed
unsigned _new_speed
 the new speed requested to set
unsigned _last_step
 the last step set
int _last_cpu_load
 set last cpu load
string USERSPACE_STRING
 name of userspace governor to write to governor file

Detailed Description

Class to control one CPU's frequency by the powersave daemon.


Constructor & Destructor Documentation

CPUFreq_Userspace::CPUFreq_Userspace std::list< int >  cpu_cores  ) 
 

constructor

Parameters:
cpu_cores stl list containing all cores the object has to care about

CPUFreq_Userspace::~CPUFreq_Userspace  ) 
 

destructor


Member Function Documentation

int CPUFreq_Userspace::adjustSpeed  )  [private, virtual]
 

adjusts speeds

Returns:
  • -1 if speed has been decreased
  • 1 if speed has been increased
  • 0 if speed has not been modified

Implements CPUFreq_Interface.

void CPUFreq_Userspace::createHysteresisArray  )  [private]
 

creates the hysteresis array

int CPUFreq_Userspace::decreaseSpeed  )  [private]
 

set speed to the next lower supported value

Returns:
integer with result of increase speed
Return values:
0 if maximum is already reached
1 if new speed could be set
-1 if mode is not userspace

bool CPUFreq_Userspace::getMinMaxSpeeds unsigned long *  min,
unsigned long *  max
[private]
 

get the minimum and maximum available speeds

This is currently only used by the userspace class to test frequencies if available_frequencies file is not exported by the kernel's low-level driver

Parameters:
min value is set to the minimum speed
max value is set to the maximum speed
Returns:
false if speedstepping is not supported

unsigned CPUFreq_Userspace::getSpeed  )  [private]
 

get the current CPU speed

Returns:
the speed or 0 on error

int CPUFreq_Userspace::increaseSpeed  )  [private]
 

set speed to the next higher supported value

Returns:
integer with result of increase speed
Return values:
0 if maximum is already reached
1 if new speed could be set
-1 if mode is not userspace

bool CPUFreq_Userspace::init  )  [virtual]
 

init cpufreq interface and set userspace governor

Returns:
true on success, false otherwise

Implements CPUFreq_Interface.

int CPUFreq_Userspace::initFreqsViaFile  )  [private]
 

inits the available speeds via reading from file

Returns:
< 0 on error

int CPUFreq_Userspace::initFreqsViaTesting  )  [private]
 

inits the available speeds via testing

Returns:
< 0 on error

bool CPUFreq_Userspace::readFrequencies  )  [private, virtual]
 

reads out frequencies

Returns:
false on error

Implements CPUFreq_Interface.

void CPUFreq_Userspace::reinitSpeed  )  [private, virtual]
 

reinits speeds

function for suspend workaround. after resuming the frequency might have changed and we haven't recognized. This could possibly break old PowerNow! machines, but as far as I know jumping more than one frequency at once is fixed in kernel module for that machines

Implements CPUFreq_Interface.

void CPUFreq_Userspace::setConfig  )  [private, virtual]
 

set configuration in initialize values

Implements CPUFreq_Interface.

void CPUFreq_Userspace::setSpeed unsigned  current,
unsigned  target
[private]
 

set the speed smoothly in steps

This code smoothly transitions the CPU speed from 'current' to 'target' instead of jumping directly to the new speed because some AMD Mobile Athlon parts seem to choke on large differentials causing kernel panics.

Parameters:
current the current speed
target the target speed

bool CPUFreq_Userspace::setSpeed unsigned  kHz  )  [private]
 

set the current CPU speed

Parameters:
kHz the speed in kHz to set
Returns:
false if speed could not be set


Member Data Documentation

unsigned CPUFreq_Userspace::_current_speed [private]
 

the current set speed

unsigned CPUFreq_Userspace::_demotion[MAX_SPEEDS+1] [private]
 

demotion

int CPUFreq_Userspace::_last_cpu_load [private]
 

set last cpu load

unsigned CPUFreq_Userspace::_last_step [private]
 

the last step set

unsigned CPUFreq_Userspace::_new_speed [private]
 

the new speed requested to set

unsigned CPUFreq_Userspace::_speeds_kHz[MAX_SPEEDS+1] [private]
 

array containing available speeds

string CPUFreq_Userspace::CURRENT_SPEED_FILE [private]
 

speed file to get or set current speed

string CPUFreq_Userspace::USERSPACE_STRING [private]
 

name of userspace governor to write to governor file


The documentation for this class was generated from the following files:
Generated on Mon Mar 27 09:27:19 2006 for Powersave Daemon by  doxygen 1.4.6