Group :: System/Kernel and hardware
RPM: cpufreqd
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: cpufreqd-2.4.3-alt3.patch
Download
Download
.gear/rules | 4 +
.../tags/1c95ed6952981d325dbee9bd5289af13c671da32 | 6 +
.gear/tags/list | 1 +
cpufreqd.conf | 6 +-
cpufreqd.init.alt | 103 +++++++++++++
cpufreqd.service | 10 ++
cpufreqd.spec | 163 +++++++++++++++++++++
src/cpufreqd_acpi_battery.c | 109 ++++++++++----
8 files changed, 372 insertions(+), 30 deletions(-)
diff --git a/.gear/rules b/.gear/rules
new file mode 100644
index 0000000..1eb417e
--- /dev/null
+++ b/.gear/rules
@@ -0,0 +1,4 @@
+tar: r@version@:.
+diff: r@version@:. .
+copy: *.alt
+copy: *.service
diff --git a/.gear/tags/1c95ed6952981d325dbee9bd5289af13c671da32 b/.gear/tags/1c95ed6952981d325dbee9bd5289af13c671da32
new file mode 100644
index 0000000..4b640b7
--- /dev/null
+++ b/.gear/tags/1c95ed6952981d325dbee9bd5289af13c671da32
@@ -0,0 +1,6 @@
+object 9643c2e1f33aed8ea92f03904eb3be9a8d5afa8f
+type commit
+tag r2.4.3
+tagger Alexey Shabalin <shaba@altlinux.org> 1298312918 +0300
+
+r2.4.3
diff --git a/.gear/tags/list b/.gear/tags/list
new file mode 100644
index 0000000..decd3e8
--- /dev/null
+++ b/.gear/tags/list
@@ -0,0 +1 @@
+1c95ed6952981d325dbee9bd5289af13c671da32 r2.4.3
diff --git a/cpufreqd.conf b/cpufreqd.conf
index b076fcb..9d66e7f 100644
--- a/cpufreqd.conf
+++ b/cpufreqd.conf
@@ -4,7 +4,7 @@
[General]
pidfile=/var/run/cpufreqd.pid
poll_interval=2
-verbosity=4
+verbosity=3
#enable_remote=1
#remote_group=root
[/General]
@@ -27,6 +27,7 @@ name=On Demand High
minfreq=40%
maxfreq=100%
policy=ondemand
+exec_pre=cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
[/Profile]
[Profile]
@@ -41,6 +42,7 @@ name=Performance High
minfreq=100%
maxfreq=100%
policy=performance
+exec_pre=cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
#exec_post=echo 8 > /proc/acpi/sony/brightness
[/Profile]
@@ -132,7 +134,7 @@ profile=Performance Low
# But don't heat too much.
[Rule]
name=Movie Watcher
-programs=xine,mplayer,gmplayer
+programs=xine,mplayer,avidemux,gcc,totem,vlc,kaffeine,ogle,lindvd
battery_interval=0-100
acpi_temperature=0-60
cpu_interval=0-100
diff --git a/cpufreqd.init.alt b/cpufreqd.init.alt
new file mode 100644
index 0000000..80c4c3c
--- /dev/null
+++ b/cpufreqd.init.alt
@@ -0,0 +1,103 @@
+#!/bin/sh
+#
+# cpufreqd Startup script for the cpufreqd daemon.
+#
+# chkconfig: 345 70 50
+# description: cpufreqd - CPU frequency scaling daemon \
+# it monitors battery level, AC state and \
+# running programs and adjusts the frequency of the processor.
+# processname: cpufreqd
+# config: /etc/cpufreqd.conf
+# pidfile: /var/run/cpufreqd.pid
+
+### BEGIN INIT INFO
+# Provides: cpufreqd
+# Required-Start: $local_fs $syslog
+# Required-Stop: $local_fs $syslog
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: CPU frequency scaling daemon
+# Description: CPU frequency scaling daemon
+### END INIT INFO
+
+# Do not load RH compatibility interface.
+WITHOUT_RC_COMPAT=1
+
+# Source function library.
+. /etc/init.d/functions
+
+RETVAL=0
+
+[ -d /sys/devices/system/cpu/cpu0/cpufreq ] || [ -f /proc/cpufreq ] || exit 0
+
+PIDFILE=/var/run/cpufreqd.pid
+LOCKFILE=/var/lock/subsys/cpufreqd
+
+start()
+{
+ start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- cpufreqd -f /etc/cpufreqd.conf
+ RETVAL=$?
+ return $RETVAL
+}
+
+stop()
+{
+ stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- cpufreqd
+ RETVAL=$?
+ [ -d /sys/devices/system/cpu/cpu0/cpufreq ] && cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq
+ return $RETVAL
+}
+
+restart()
+{
+ stop
+ start
+}
+
+reload()
+{
+ msg_reloading template
+ stop_daemon --pidfile "$PIDFILE" --expect-user root -HUP -- cpufreqd
+ RETVAL=$?
+ return $RETVAL
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ reload)
+ reload
+ ;;
+ restart)
+ restart
+ ;;
+ condstop)
+ if [ -e "$LOCKFILE" ]; then
+ stop
+ fi
+ ;;
+ condrestart)
+ if [ -e "$LOCKFILE" ]; then
+ restart
+ fi
+ ;;
+ condreload)
+ if [ -e "$LOCKFILE" ]; then
+ reload
+ fi
+ ;;
+ status)
+ status --pidfile "$PIDFILE" --expect-user root -- cpufreqd
+ RETVAL=$?
+ ;;
+ *)
+ msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}"
+ RETVAL=1
+esac
+
+exit $RETVAL
diff --git a/cpufreqd.service b/cpufreqd.service
new file mode 100644
index 0000000..2249ae9
--- /dev/null
+++ b/cpufreqd.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Cpufreqd daemon
+After=acpid.service
+
+[Service]
+ExecStart=/usr/sbin/cpufreqd -D
+ExecStop=/bin/kill -INT $MAINPID
+
+[Install]
+WantedBy=multi-user.target
diff --git a/cpufreqd.spec b/cpufreqd.spec
new file mode 100644
index 0000000..cef6f1e
--- /dev/null
+++ b/cpufreqd.spec
@@ -0,0 +1,163 @@
+%def_disable static
+%def_enable acpi
+%def_enable nforce2
+%def_enable apm
+%def_enable sensors
+%def_enable pmu
+%def_enable exec
+%def_enable tau
+
+
+Summary: CPU frequency scaling daemon
+Name: cpufreqd
+Version: 2.4.3
+Release: alt3
+Url: http://sourceforge.net/projects/cpufreqd/
+License: GPLv2
+Group: System/Kernel and hardware
+Packager: Alexey Shabalin <shaba@altlinux.ru>
+
+Source0: %name-%version.tar
+Source1: %name.init.alt
+Source2: %name.service
+Patch0: %name-%version-%release.patch
+
+BuildRequires: gcc-c++ libcpufreq-devel libsysfs-devel
+%{?_enable_sensors:BuildRequires: libsensors3-devel}
+Requires: cpufrequtils
+
+%description
+Cpufreqd is meant to be a replacement of the speedstep applet you
+can find on some other OS, it monitors battery level, AC state and
+running programs and adjusts the frequency of the processor according to
+a set of rules specified in the config file (see cpufreqd.conf (5)).
+
+Cpufreqd 2 aims to become the next generation power management
+daemon. It provides a common interface to enable system monitoring
+and to take useful actions upon that.
+Currently it is still centered on the CPUFreq kernel interface,
+that means that running a CPUFreq capable kernel is still needed but
+also that behaviour could be delegated to a plugin.
+
+Note that the configuration file format is slightly incompatible
+with the previous cpufreqd 1 but it's really easy to migrate (a
+simple Perl script could do it, I'll try to prepare one soon).
+
+%prep
+%setup -q
+%patch0 -p1
+
+%build
+%__aclocal
+%__libtoolize -c -f
+%__aclocal
+%__autoconf
+%__automake -a -c --foreign
+
+%configure \
+ %{subst_enable static} \
+ %{subst_enable acpi} \
+ %{subst_enable nforce2} \
+ %{subst_enable apm} \
+ %{subst_enable sensors} \
+ %{subst_enable pmu} \
+ %{subst_enable exec} \
+ --enable-governor-parameters \
+ %{subst_enable tau} \
+ --localstatedir=%_var \
+ --libdir=%_libdir/%name
+# libdir need only for plugins
+
+%make_build
+
+%install
+%make DESTDIR=%buildroot install
+
+install -d %buildroot{%_initdir,%systemd_unitdir}
+install %SOURCE1 %buildroot%_initdir/%name
+install %SOURCE2 %buildroot%systemd_unitdir/%name.service
+
+# remove non-packaged files
+rm -f %buildroot%_libdir/%name/*.la
+
+%post
+%post_service cpufreqd
+
+%preun
+%preun_service cpufreqd
+
+%files
+%doc AUTHORS COPYING INSTALL README NEWS TODO ChangeLog
+%_sbindir/*
+%_bindir/*
+%dir %_libdir/cpufreqd
+%_libdir/cpufreqd/*.so
+%attr(644,root,root) %config(noreplace) %_sysconfdir/%name.conf
+%_initdir/%name
+%systemd_unitdir/%name.service
+%_mandir/man?/*
+
+%changelog
+* Fri Feb 02 2018 Aleksei Nikiforov <darktemplar@altlinux.org> 2.4.3-alt3
+- Fixed localstatedir location.
+
+* Fri Apr 06 2012 Alexey Shabalin <shaba@altlinux.ru> 2.4.3-alt2
+- fix for kernel >= 2.6.36
+- add systemd service
+
+* Mon Feb 21 2011 Alexey Shabalin <shaba@altlinux.ru> 2.4.3-alt1
+- 2.4.3
+
+* Wed Apr 21 2010 Alexey Shabalin <shaba@altlinux.ru> 2.4.2-alt1
+- 2.4.2
+
+* Tue Apr 13 2010 Mykola Grechukh <gns@altlinux.ru> 2.3.4-alt2.git.e4bbd.1
+- patch from bugzilla aplied (closes: #22923)
+
+* Thu Feb 04 2010 Alexey Shabalin <shaba@altlinux.ru> 2.3.4-alt2.git.e4bbd
+- git snapshot e4bbd57e6f201f90a91550b381e347f7a1b6fcd5
+
+* Tue May 05 2009 Alexey Shabalin <shaba@altlinux.ru> 2.3.4-alt1
+- 2.3.4
+- build from git
+
+* Fri Oct 17 2008 Alexey Shabalin <shaba@altlinux.ru> 2.3.3-alt1
+- 2.3.3
+- fix work with two batteries(patch3)
+
+* Mon Aug 04 2008 Alexey Shabalin <shaba@altlinux.ru> 2.3.0-alt1
+- 2.3.0
+- move plugins from %_libdir to %_libdir/%name
+
+* Tue Apr 24 2007 Alexey Shabalin <shaba@altlinux.ru> 2.2.1-alt1
+- 2.2.1
+- clean spec
+- add more programs to rule in cpufreqd.conf (patch1)
+- fix restore maximum cpu (patch2)
+
+* Tue Jan 10 2006 Alexey Shabalin <shaba@altlinux.ru> 2.0.0-alt1
+- 2.0.0 of the next generation verion
+- remove two config files (only one for kernel-2.6)
+
+* Mon Jun 27 2005 Alexey Shabalin <shaba@altlinux.ru> 1.2.3-alt2
+- fix init script (#7007)
+
+* Tue May 24 2005 Alexey Shabalin <shaba@altlinux.ru> 1.2.3-alt1
+- update 1.2.3
+
+* Mon Apr 25 2005 Alexey Shabalin <shaba@altlinux.ru> 1.2.2-alt1
+- update cpufreqd-1.1.2
+- add two config files cpufregd.conf-2.4 and cpufreqd.conf-2.6
+- autoselect config file for 2.4 or 2.6 kernel
+
+* Sun Oct 03 2004 Alexey Shabalin <shaba@altlinux.ru> 1.2.0-alt1
+- new version 1.2.0
+
+* Mon Mar 15 2004 Alexey Shabalin <shaba@altlinux.ru> 1.1.2-alt1
+- update cpufreqd-1.1.2
+- remove /etc/sysconfig/cpufreqd
+- update init scripts
+
+* Wed Jan 07 2004 Alexey Shabalin <shaba@altlinux.ru> 1.1-alt1
+- initial release
+
diff --git a/src/cpufreqd_acpi_battery.c b/src/cpufreqd_acpi_battery.c
index e2da172..9c8148e 100644
--- a/src/cpufreqd_acpi_battery.c
+++ b/src/cpufreqd_acpi_battery.c
@@ -29,12 +29,15 @@
#define POWER_SUPPLY "power_supply"
#define BATTERY_TYPE "Battery"
+#define PRESENT "present"
+#define STATUS "status"
+//energy batter properties
#define ENERGY_FULL "energy_full"
#define ENERGY_NOW "energy_now"
+#define POWER_NOW "power_now"
+//charge battery properties
#define CHARGE_FULL "charge_full"
#define CHARGE_NOW "charge_now"
-#define PRESENT "present"
-#define STATUS "status"
#define CURRENT_NOW "current_now"
struct battery_info {
@@ -45,11 +48,11 @@ struct battery_info {
int is_present;
struct sysfs_class_device *cdev;
- struct sysfs_attribute *energy_full; /* last full capacity */
- struct sysfs_attribute *energy_now; /* remaining capacity */
+ struct sysfs_attribute *full_capacity; /* last full capacity */
+ struct sysfs_attribute *remaining_capacity; /* remaining capacity */
struct sysfs_attribute *present;
struct sysfs_attribute *status;
- struct sysfs_attribute *current_now; /* present rate */
+ struct sysfs_attribute *draw_rate; /* present rate */
int open;
};
@@ -87,16 +90,16 @@ static void close_battery(struct battery_info *binfo) {
if (!binfo->open) return;
- if (binfo->energy_full)
- put_attribute(binfo->energy_full);
- if (binfo->energy_now)
- put_attribute(binfo->energy_now);
+ if (binfo->full_capacity)
+ put_attribute(binfo->full_capacity);
+ if (binfo->remaining_capacity)
+ put_attribute(binfo->remaining_capacity);
if (binfo->present)
put_attribute(binfo->present);
if (binfo->status)
put_attribute(binfo->status);
- if (binfo->current_now)
- put_attribute(binfo->current_now);
+ if (binfo->draw_rate)
+ put_attribute(binfo->draw_rate);
binfo->open = 0;
}
@@ -104,11 +107,11 @@ static void close_battery(struct battery_info *binfo) {
static int read_battery(struct battery_info *binfo) {
clog(LOG_DEBUG, "%s - reading battery levels\n", binfo->cdev->name);
- if (read_int(binfo->current_now, &binfo->present_rate) != 0) {
+ if (read_int(binfo->draw_rate, &binfo->present_rate) != 0) {
clog(LOG_ERR, "Skipping %s\n", binfo->cdev->name);
return -1;
}
- if (read_int(binfo->energy_now, &binfo->remaining) != 0) {
+ if (read_int(binfo->remaining_capacity, &binfo->remaining) != 0) {
clog(LOG_ERR, "Skipping %s\n", binfo->cdev->name);
return -1;
}
@@ -120,38 +123,88 @@ static int read_battery(struct battery_info *binfo) {
binfo->cdev->name, binfo->remaining);
return 0;
}
+
+/* open energy battery specific attributes */
+static int read_energy_battery_attributes(struct battery_info *binfo)
+{
+ binfo->full_capacity = get_class_device_attribute(binfo->cdev, ENERGY_FULL);
+ if(!binfo->full_capacity)
+ {
+ return -1;
+ }
+
+ binfo->remaining_capacity = get_class_device_attribute(binfo->cdev, ENERGY_NOW);
+ if(!binfo->remaining_capacity)
+ {
+ return -1;
+ }
+
+ binfo->draw_rate = get_class_device_attribute(binfo->cdev, POWER_NOW);
+ if(!binfo->draw_rate)
+ {
+ return -1;
+ }
+
+ return 0;
+}
+
+/* open charge battery specific attributes */
+static int read_charge_battery_attributes(struct battery_info *binfo)
+{
+ binfo->full_capacity = get_class_device_attribute(binfo->cdev, CHARGE_FULL);
+ if(!binfo->full_capacity)
+ {
+ return -1;
+ }
+
+ binfo->remaining_capacity = get_class_device_attribute(binfo->cdev, CHARGE_NOW);
+ if(!binfo->remaining_capacity)
+ {
+ return -1;
+ }
+
+ binfo->draw_rate = get_class_device_attribute(binfo->cdev, CURRENT_NOW);
+ if(!binfo->draw_rate)
+ {
+ return -1;
+ }
+
+ return 0;
+}
+
/* open all the required attributes and set the open status */
static int open_battery(struct battery_info *binfo) {
binfo->open = 1;
- binfo->energy_full = get_class_device_attribute(binfo->cdev, ENERGY_FULL);
- if (!binfo->energy_full) {
- /* try the "charge_full" name */
- binfo->energy_full = get_class_device_attribute(binfo->cdev,
- CHARGE_FULL);
- if (!binfo->energy_full)
+ //attempt to open energy attribute
+ struct sysfs_attribute *tmp_attribute = get_class_device_attribute(binfo->cdev, ENERGY_FULL);
+
+ if(!tmp_attribute)
+ {
+ if(read_charge_battery_attributes(binfo) != 0)
+ {
return -1;
+ }
}
- binfo->energy_now = get_class_device_attribute(binfo->cdev, ENERGY_NOW);
- if (!binfo->energy_now) {
- /* try the "charge_now" name */
- binfo->energy_now = get_class_device_attribute(binfo->cdev, CHARGE_NOW);
- if (!binfo->energy_now)
+ else
+ {
+ put_attribute(tmp_attribute);
+ if(read_energy_battery_attributes(binfo) != 0)
+ {
return -1;
+ }
}
+
binfo->present = get_class_device_attribute(binfo->cdev, PRESENT);
if (!binfo->present)
return -1;
binfo->status = get_class_device_attribute(binfo->cdev, STATUS);
if (!binfo->status)
return -1;
- binfo->current_now = get_class_device_attribute(binfo->cdev, CURRENT_NOW);
- if (!binfo->current_now)
- return -1;
/* read the last full capacity, this is not going to change
* very often, so no need to poke it later */
- if (read_int(binfo->energy_full, &binfo->capacity) != 0) {
+ if (read_int(binfo->full_capacity, &binfo->capacity) != 0) {
clog(LOG_WARNING, "Couldn't read %s capacity (%s)\n",
binfo->cdev->name, strerror(errno));
return -1;