2
* Copyright (C) 2002-2005 Mattia Dongili<dongili@supereva.it>
3
* George Staikos <staikos@0wned.org>
5
* Copyright (C) 2003-2005 Rene Rebe <rene@rocklinux.org>
8
* - added support for cpu monitoring, base code by Dietz Proepper and minor
9
* fixes by Mattia Dongili
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; either version 2 of the License, or
14
* (at your option) any later version.
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
23
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35
#include <sys/types.h>
48
#include "string_list.h"
50
#define _CPUFREQD_VERSION_ "1.2.3"
56
#ifndef CPUFREQD_CONFDIR
57
#define CPUFREQD_CONFDIR "/etc/"
60
#ifndef CPUFREQD_LIBDIR
61
#define CPUFREQD_LIBDIR ""
64
#ifndef CPUFREQD_STATEDIR
65
#define CPUFREQD_STATEDIR "/var/"
68
#define CPUFREQD_CONFIG CPUFREQD_CONFDIR"cpufreqd.conf"
69
#define CPUFREQD_PIDFILE CPUFREQD_STATEDIR"run/cpufreqd.pid"
70
#define APM_PROC_FILE "/proc/apm"
71
#define ACPI_PROC_DIR "/proc/acpi/"
72
#define ACPI_BATTERY_DIR "/proc/acpi/battery/"
73
#define ACPI_AC_DIR "/proc/acpi/ac_adapter/"
74
#define PMU_PROC_DIR "/proc/pmu"
75
#define CPUINFO_PROC "/proc/cpuinfo"
77
#define CPUFREQ_SYSFS_INTERFACE "/sys/devices/system/cpu/cpu0/cpufreq"
78
#define CPUFREQ_SYSFS_INTERFACE_POLICY "/sys/devices/system/cpu/cpu%i/cpufreq/scaling_governor"
79
#define CPUFREQ_SYSFS_INTERFACE_MAX "/sys/devices/system/cpu/cpu%i/cpufreq/scaling_max_freq"
80
#define CPUFREQ_SYSFS_INTERFACE_MIN "/sys/devices/system/cpu/cpu%i/cpufreq/scaling_min_freq"
81
#define CPUFREQ_SYSFS_INTERFACE_CPUMAX "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"
82
#define CPUFREQ_SYSFS_INTERFACE_CPUMIN "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq"
83
#define CPUFREQ_PROC_INTERFACE "/proc/cpufreq"
84
#define CPUFREQ_PROC_INTERFACE_SPEED "/proc/sys/cpu/0/speed"
85
#define CPUFREQ_PROC_INTERFACE_MIN "/proc/sys/cpu/0/speed-min"
86
#define CPUFREQ_PROC_INTERFACE_MAX "/proc/sys/cpu/0/speed-max"
88
/* kernel version constants */
97
typedef struct interval battery_interval;
98
typedef struct interval cpu_interval;
100
typedef struct profile {
105
char policy_name[255];
106
struct profile *next;
109
/* TODO: add precedence factor for rules having he same score */
110
/* TODO: add a command to be executed after the rule is activated */
111
typedef struct rule {
113
unsigned int ac; /* AC power state */
114
battery_interval *bat;
116
float cpu_nice_scale; /* how much will nice cpu time influence this rule? */
117
int delay_cycles; /* # of cycles this rule can wait before being applyed */
118
char profile_name[255];
119
struct string_list *program_list;
125
typedef struct sys_info {
129
int old_weighted_activity;
130
int cur_sys_activity;
131
int cur_nice_activity;
144
#define MATCH_BATTERY 2
147
#define DEFAULT_NICE_SCALE 3
148
#define DEFAULT_VERBOSITY 4
149
#define DEFAULT_POLL 1
150
#define DEFAULT_PMPLUGIN "acpi"
153
char config_file[512];
156
unsigned int poll_interval;
158
unsigned int has_sysfs;
159
unsigned int no_daemon;
160
unsigned int log_level_overridden;
161
unsigned int acpi_workaround;
162
long int cpu_min_freq;
163
long int cpu_max_freq;