summaryrefslogtreecommitdiffstats
path: root/src/hardware_cpu.h
blob: 7d9c94d57e0def13d48f11eb4de6c56fa183aab5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
 /**************************************************************************
 *   Copyright (C) 2006 by Daniel Gollub                                   *
 *                            <dgollub@suse.de>                            *
 *                         Danny Kukawka                                   *
 *                            <dkukawka@suse.de>, <danny.kukawka@web.de>   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of version 2 of the GNU General Public License     *
 *   as published by the Free Software Foundation.                         *
 *                                                                         *
 *   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, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.             *
 ***************************************************************************/
 
/*! 
*  \file 	hardware_cpu.h
*  \brief 	Headerfile for hardware_cpu.cpp and the class \ref CPUInfo.
*/
/*! 
*  \class 	CPUInfo
*  \brief 	class for CPU information related funtionality
*  \author 	Danny Kukawka, <dkukawka@suse.de>, <danny.kukawka@web.de>
*  \date    	2006
*/

#ifndef _HARDWARE_CPU_H_
#define _HARDWARE_CPU_H_

// Global Header
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

// QT Headers
#include <tqstring.h>
#include <tqobject.h>
#include <tqvaluelist.h>

// TDE hardware library
#include <tdehardwaredevices.h>

// own headers
#include "kpowersave_debug.h"

class CPUInfo : public TQObject{

	Q_OBJECT
  

private:

	//! Integer with the numbers of CPUs in the system
	/*! This contains the number of CPUs in the current system */
	int numOfCPUs;

	TDEHardwareDevices *m_hwdevices;

public:

	//! represent the current Throttling of the CPU
	/*!
	* This interge value represent the current throttling step of the CPU in percent
	* \li a value >= 0 in %
	*/
	TQValueList <int> cpu_throttling;
		
	//! represent the current CPU speeds
	/*!
	* This integer value represent the current speed/frequency of the CPUs in Mhz
	* \li a value > 0 in Mhz
	*/
	TQValueList <int> cpufreq_speed;

	//! represent the max. CPU speeds
	/*!
	* This integer value represent the max speed/frequency of the CPUs in Mhz
	* \li a value > 0 in Mhz
	*/
	TQValueList <int> cpufreq_max_speed;

	//! if the machine support change CPU Freq in general
	/*! 
	* This boolean represent information if the machine support change the 
	* CPU freqency in general vi sysfs
	* \li true: 	if supported
	* \li false: 	else
	*/
	bool cpuFreqHW;
	//! tells if the  CPUFreq Speed changed
	/*! 
	* This boolean represent information about CPUFreq Speed changes.
	* \li true: if something changed
	* \li false: if nothing changed (or this is reset to false if the message was consumed)
	*/
	bool update_info_cpufreq_speed_changed;

	// --> functions
	//! default constructor
	CPUInfo();
	//! default destructor
	~CPUInfo();

	//! checks the current CPU Speed from sysfs
	int checkCPUSpeed();
	//! checks the Speed of throttling CPUs from /proc/cpuinfo
	int checkCPUSpeedThrottling();
	//! read the current throttling state of the CPUs from /proc/acpi/processor/CPUX/throttling
	bool getCPUThrottlingState();
	//! read the max speed of the CPUs
	void getCPUMaxSpeed();
	//! counts the total number of CPUs
	int getCPUNum();
};
#endif