.gear/rules | 3 + .gear/tags/list | 1 + cpufreqd.conf | 6 +- cpufreqd.init.alt | 103 ++++++++++++++++++++++++++++++++ cpufreqd.spec | 139 +++++++++++++++++++++++++++++++++++++++++++ src/cpufreqd_acpi_battery.c | 6 ++- 6 files changed, 255 insertions(+), 3 deletions(-) diff --git a/.gear/rules b/.gear/rules new file mode 100644 index 0000000..8bcc7da --- /dev/null +++ b/.gear/rules @@ -0,0 +1,3 @@ +tar: r@version@:. +diff: r@version@:. . +copy: *.alt \ No newline at end of file diff --git a/.gear/tags/list b/.gear/tags/list new file mode 100644 index 0000000..8584c97 --- /dev/null +++ b/.gear/tags/list @@ -0,0 +1 @@ +914c5e7c77763346abaf63e39d2d317c60d792c2 r2.3.4 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.spec b/cpufreqd.spec new file mode 100644 index 0000000..708be02 --- /dev/null +++ b/cpufreqd.spec @@ -0,0 +1,139 @@ +%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.3.4 +Release: alt1 +Url: http://sourceforge.net/projects/cpufreqd/ +License: GPLv2 +Group: System/Kernel and hardware +Packager: Alexey Shabalin + +Source0: %name-%version.tar +Source1: %name.init.alt +Patch0: %name-%version-%release.patch + +BuildRequires: gcc-c++ libcpufreq-devel libsysfs-devel +%{?_enable_sensors:BuildRequires: libsensors-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} \ + --libdir=%_libdir/%name +# libdir need only for plugins + +%make_build + +%install +%make DESTDIR=%buildroot install + +install -d %buildroot%_initdir +install %SOURCE1 %buildroot%_initdir/%name + +# 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/* +%_libdir/* +%attr(644,root,root) %config(noreplace) %_sysconfdir/%name.conf +%_initdir/%name +%_mandir/man?/* + +%changelog +* Tue May 05 2009 Alexey Shabalin 2.3.4-alt1 +- 2.3.4 +- build from git + +* Fri Oct 17 2008 Alexey Shabalin 2.3.3-alt1 +- 2.3.3 +- fix work with two batteries(patch3) + +* Mon Aug 04 2008 Alexey Shabalin 2.3.0-alt1 +- 2.3.0 +- move plugins from %_libdir to %_libdir/%name + +* Tue Apr 24 2007 Alexey Shabalin 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 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 1.2.3-alt2 +- fix init script (#7007) + +* Tue May 24 2005 Alexey Shabalin 1.2.3-alt1 +- update 1.2.3 + +* Mon Apr 25 2005 Alexey Shabalin 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 1.2.0-alt1 +- new version 1.2.0 + +* Mon Mar 15 2004 Alexey Shabalin 1.1.2-alt1 +- update cpufreqd-1.1.2 +- remove /etc/sysconfig/cpufreqd +- update init scripts + +* Wed Jan 07 2004 Alexey Shabalin 1.1-alt1 +- initial release + diff --git a/src/cpufreqd_acpi_battery.c b/src/cpufreqd_acpi_battery.c index 693a7cd..0c7a723 100644 --- a/src/cpufreqd_acpi_battery.c +++ b/src/cpufreqd_acpi_battery.c @@ -325,7 +325,6 @@ int acpi_battery_update(void) { /* if check_timeout is expired */ if (check_timeout <= 0) { - check_timeout = acpi_config.battery_update_interval; if (read_battery(&info[i]) == 0) n_read++; else @@ -365,6 +364,11 @@ int acpi_battery_update(void) { #endif } /* end info loop */ + /* check_timeout is global for all batteries, so update it after all batteries got updated */ + if (check_timeout <= 0) { + check_timeout = acpi_config.battery_update_interval; + } + /* calculates medium battery life between all batteries */ if (total_capacity > 0) avg_battery_level = 100 * (total_remaining / (double)total_capacity);