--- powertop-1.13.orig/powertop.h +++ powertop-1.13/powertop.h @@ -28,6 +28,16 @@ #include +/* + * Define the MAX values for [CP]STATES "big enough". + * Defining it too less will result in missing some C/P state information. + * Defining the values too high will result in memory wastage. + */ +#define MAX_NUM_CSTATES 10 +#define MAX_NUM_PSTATES 16 + +#define MAX_CSTATE_LINES (MAX_NUM_CSTATES + 3) + struct line { char *string; int count; @@ -41,6 +51,8 @@ extern int linehead; extern int linesize; extern int linectotal; +extern int maxcstate; +extern int maxpstate; extern double displaytime; @@ -70,8 +82,8 @@ -extern char cstate_lines[12][200]; -extern char cpufreqstrings[6][80]; +extern char cstate_lines[MAX_CSTATE_LINES][200]; +extern char cpufreqstrings[MAX_NUM_PSTATES+1][80]; extern int topcstate; extern int topfreq; --- powertop-1.13.orig/powertop.c +++ powertop-1.13/powertop.c @@ -41,9 +41,9 @@ #include "powertop.h" -uint64_t start_usage[8], start_duration[8]; -uint64_t last_usage[8], last_duration[8]; -char cnames[8][16]; +uint64_t start_usage[MAX_NUM_CSTATES], start_duration[MAX_NUM_CSTATES]; +uint64_t last_usage[MAX_NUM_CSTATES], last_duration[MAX_NUM_CSTATES]; +char cnames[MAX_NUM_CSTATES][16]; double ticktime = 15.0; @@ -51,7 +51,8 @@ int showpids = 0; -static int maxcstate = 0; +int maxcstate; +int maxpstate; int topcstate = 0; int dump = 0; @@ -450,6 +451,10 @@ sprintf(cnames[clevel], "%s\t", "C1 halt"); } } + + if (clevel > maxcstate) + maxcstate = clevel; + sprintf(filename + len, "/%s/usage", entry->d_name); file = fopen(filename, "r"); if (!file) @@ -477,9 +482,6 @@ duration[clevel] += 1+strtoull(line, NULL, 10); clevel++; - if (clevel > maxcstate) - maxcstate = clevel; - } closedir(dir); @@ -824,7 +826,7 @@ show_acpi_power_line(rate, cap, prev_bat_cap - cap, time(NULL) - prev_bat_time); } -char cstate_lines[12][200]; +char cstate_lines[MAX_CSTATE_LINES][200]; void usage() { @@ -848,7 +850,7 @@ char line[1024]; int ncursesinited=0; FILE *file = NULL; - uint64_t cur_usage[8], cur_duration[8]; + uint64_t cur_usage[MAX_NUM_CSTATES], cur_duration[MAX_NUM_CSTATES]; double wakeups_per_second = 0; setlocale (LC_ALL, ""); @@ -957,25 +959,22 @@ do_proc_irq(); read_data(&cur_usage[0], &cur_duration[0]); + if (maxcstate >= MAX_NUM_CSTATES) { + printf("Actual CSTATES (%d) > MAX_NUM_CSTATES (%d)!\n", + maxcstate+1, MAX_NUM_CSTATES); + exit(1); + } + totalticks = 0; totalevents = 0; - for (i = 0; i < 8; i++) + for (i = 0; i <= maxcstate; i++) if (cur_usage[i]) { totalticks += cur_duration[i] - last_duration[i]; totalevents += cur_usage[i] - last_usage[i]; } - if (!dump) { - if (!ncursesinited) { - initialize_curses(); - ncursesinited++; - } - setup_windows(); - show_title_bar(); - } - memset(&cstate_lines, 0, sizeof(cstate_lines)); - topcstate = -4; + topcstate = -(maxcstate); if (totalevents == 0 && maxcstate <= 1) { sprintf(cstate_lines[5],_("< Detailed C-state information is not available.>\n")); } else { @@ -989,7 +988,7 @@ sprintf(cstate_lines[1], _("C0 (cpu running) (%4.1f%%)\n"), percentage); if (percentage > 50) topcstate = 0; - for (i = 0; i < 8; i++) + for (i = 0; i <= maxcstate; i++) if (cur_usage[i]) { sleept = (cur_duration[i] - last_duration[i]) / (cur_usage[i] - last_usage[i] + 0.1) / FREQ; @@ -1010,6 +1009,21 @@ } } do_cpufreq_stats(); + + if (maxpstate > MAX_NUM_PSTATES) { + printf("Actual PSTATES (%d) > MAX_NUM_PSTATES (%d)!\n", + maxpstate, MAX_NUM_PSTATES); + exit(1); + } + + if (!dump) { + if (!ncursesinited) { + initialize_curses(); + ncursesinited++; + } + setup_windows(); + show_title_bar(); + } show_cstates(); /* now the timer_stats info */ memset(line, 0, sizeof(line)); --- powertop-1.13.orig/cpufreqstats.c +++ powertop-1.13/cpufreqstats.c @@ -37,12 +37,12 @@ uint64_t count; }; -struct cpufreqdata freqs[16]; -struct cpufreqdata oldfreqs[16]; +struct cpufreqdata freqs[MAX_NUM_PSTATES]; +struct cpufreqdata oldfreqs[MAX_NUM_PSTATES]; -struct cpufreqdata delta[16]; +struct cpufreqdata delta[MAX_NUM_PSTATES]; -char cpufreqstrings[6][80]; +char cpufreqstrings[MAX_NUM_PSTATES+1][80]; int topfreq = -1; static void zap(void) @@ -114,7 +114,7 @@ memset(&cpufreqstrings, 0, sizeof(cpufreqstrings)); sprintf(cpufreqstrings[0], _("P-states (frequencies)\n")); - for (ret = 0; ret<16; ret++) + for (ret = 0; ret < MAX_NUM_PSTATES; ret++) freqs[ret].count = 0; dir = opendir("/sys/devices/system/cpu"); @@ -153,7 +153,7 @@ if (f && maxfreq < i) maxfreq = i; i++; - if (i>15) + if (i >= MAX_NUM_PSTATES) break; } fclose(file); @@ -161,7 +161,7 @@ closedir(dir); - for (ret = 0; ret < 16; ret++) { + for (ret = 0; ret < MAX_NUM_PSTATES; ret++) { delta[ret].count = freqs[ret].count - oldfreqs[ret].count; total_time += delta[ret].count; delta[ret].frequency = freqs[ret].frequency; @@ -176,6 +176,7 @@ qsort(&delta, maxfreq+1, sizeof(struct cpufreqdata), sort_by_count); if (maxfreq>4) maxfreq=4; + maxpstate = maxfreq; qsort(&delta, maxfreq+1, sizeof(struct cpufreqdata), sort_by_freq); if (delta[0].frequency == delta[1].frequency + 1000) --- powertop-1.13.orig/display.c +++ powertop-1.13/display.c @@ -91,15 +91,20 @@ void setup_windows(void) { + int yline = (maxcstate >= maxpstate) ? maxcstate+1 : maxpstate; + + /* number of states is one more than the MAX state! */ + yline++; + getmaxyx(stdscr, maxy, maxx); zap_windows(); title_bar_window = subwin(stdscr, 1, maxx, 0, 0); - cstate_window = subwin(stdscr, 7, maxx, 2, 0); - wakeup_window = subwin(stdscr, 1, maxx, 9, 0); - battery_power_window = subwin(stdscr, 2, maxx, 10, 0); - timerstat_window = subwin(stdscr, maxy-16, maxx, 12, 0); + cstate_window = subwin(stdscr, (yline + 3), maxx, 2, 0); + wakeup_window = subwin(stdscr, 1, maxx, (yline + 4), 0); + battery_power_window = subwin(stdscr, 2, maxx, (yline + 5), 0); + timerstat_window = subwin(stdscr, maxy-16, maxx, (yline + 7), 0); maxtimerstats = maxy-16 -2; maxwidth = maxx - 18; suggestion_window = subwin(stdscr, 3, maxx, maxy-4, 0); @@ -164,20 +169,25 @@ void show_cstates(void) { int i, count = 0; + int maxcstatelines = (maxcstate >= maxpstate) ? maxcstate+1 : maxpstate; + + /* Number of states is one more than the MAX state! */ + maxcstatelines++; + werase(cstate_window); - for (i=0; i < 10; i++) { + for (i = 0; i <= maxcstatelines; i++) { if (i == topcstate+1) wattron(cstate_window, A_BOLD); else wattroff(cstate_window, A_BOLD); - if (strlen(cstate_lines[i]) && count <= 6) { + if (strlen(cstate_lines[i]) && count <= maxcstatelines) { print(cstate_window, count, 0, "%s", cstate_lines[i]); count++; } } - for (i=0; i<6; i++) { + for (i = 0; i <= (maxpstate+1); i++) { if (i == topfreq+1) wattron(cstate_window, A_BOLD); else --- powertop-1.13.orig/debian/watch +++ powertop-1.13/debian/watch @@ -0,0 +1,2 @@ +version=3 +http://www.lesswatts.org/projects/powertop/download/powertop-([\d\.]*).tar.gz --- powertop-1.13.orig/debian/compat +++ powertop-1.13/debian/compat @@ -0,0 +1 @@ +5 --- powertop-1.13.orig/debian/rules +++ powertop-1.13/debian/rules @@ -0,0 +1,11 @@ +#!/usr/bin/make -f + +include /usr/share/cdbs/1/class/makefile.mk +include /usr/share/cdbs/1/rules/debhelper.mk +#include /usr/share/cdbs/1/rules/dpatch.mk + +DEB_MAKE_INSTALL_TARGET = install BINDIR=/usr/sbin DESTDIR=`pwd`/debian/powertop +DEB_MAKE_EXTRA_ARGS = + +common-post-build-arch:: + make uptrans || true --- powertop-1.13.orig/debian/control +++ powertop-1.13/debian/control @@ -0,0 +1,27 @@ +Source: powertop +Section: utils +Priority: optional +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Patrick Winnertz +Uploaders: Jose Luis Rivas +Build-Depends: cdbs, debhelper (>= 5), libncursesw5-dev, libncurses5-dev +Standards-Version: 3.8.3 +Homepage: http://www.linuxpowertop.org + +Package: powertop +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Suggests: cpufrequtils, laptop-mode-tools +Description: Linux tool to find out what is using power on a laptop + PowerTOP is a Linux tool that finds the software component(s) that + make your laptop use more power than necessary while it is idle. As of + Linux kernel version 2.6.21, the kernel no longer has a fixed 1000Hz + timer tick. This will (in theory) give a huge power savings because + the CPU stays in low power mode for longer periods of time during + system idle. + . + However... there are many things that can ruin the party, both inside + the kernel and in userspace. PowerTOP combines various sources of + information from the kernel into one convenient screen so that you can + see how well your system is doing, and which components are the + biggest problem. --- powertop-1.13.orig/debian/changelog +++ powertop-1.13/debian/changelog @@ -0,0 +1,222 @@ +powertop (1.13-1ubuntu1) maverick; urgency=low + + * Cherrypick upstream patch 0a8620213f1841a to stop hardcoding the maximum + number of C and P states. This makes powertop work on ARM processors as + well, which have a lot of those states. Thanks to Amit Arora for the + patch! (LP: #627975) + + -- Martin Pitt Wed, 15 Sep 2010 13:43:46 +0200 + +powertop (1.13-1) unstable; urgency=low + + * New upstream version + + Should fix FTBFS an alpha (Closes: #570662) + + Fix crash with too long config files (Closes: #589438) + + -- Patrick Winnertz Thu, 29 Jul 2010 11:32:48 +0200 + +powertop (1.13~pre20100125-1) unstable; urgency=low + + * Package git snapshot from 2010-01-25 (Closes: #563498) + - fix reporting of incorrect wattage + (Closes: #497929, #558776) + - doesn't exit when xterm is resized (Closes: #488973) + - show P-states again in some rare cases (Closes: #562516) + at least this bug is not longer reproducable with this + new version + - number of wakeups should be now correct (Closes: #502596) + - manpage contains now more informations (Closes: #470498) + * remove now unneeded patches and dropped dpatch build system + * bumped standards version to 3.8.3, no further changes needed + * fix lintian warning about copyright template + + -- Patrick Winnertz Mon, 25 Jan 2010 23:20:55 +0100 + +powertop (1.11-1) unstable; urgency=low + + * New upstream release + + reports now correct wattage (at least for me) (Closes: #497929) + * Add patch in order to remove bashism in output (Closes: #509811) + * Removed patches as they are now applied upstream: + + patches/fix-eof.dpatch + + patches/add-support-for-charge_now.dpatch + + patches/fix-suggest-usb-autosuspend.dpatch + + patches/fix-hal-disable-polling.dpatch + + + -- Patrick Winnertz Tue, 13 Jan 2009 00:02:01 +0100 + +powertop (1.10-2) unstable; urgency=high + + * Support batteries that do not report energy_now, by reading change_now. + (Closes: #486873, #495638, #495348) + + -- Patrick Winnertz Mon, 01 Sep 2008 20:31:51 +0200 + +powertop (1.10-1) unstable; urgency=low + + * New upstream version (Closes: #486510) + - changed from proc to sys interface (Closes: #462796, #483603) + * Build a PO template on package build (Closes: #471852) + * spell Linux correctly: Linux (control file) + * powertop now quits if it get a EOF (Closes: 458984) + * Updated watch file (Closes: #486509) + * Removed usb patch, source has changed completely. hopefully it was fixed + by upstream. + + -- Patrick Winnertz Mon, 16 Jun 2008 23:55:10 +0200 + +powertop (1.9-2) unstable; urgency=low + + * Changed my maintainer address + * Bumped Standards-Version to 3.7.3. + * Instead of using /dev/scd0 as disk drive use /dev/cdrom for + hal-disable-polling (Created patch fix-hal-disable-polling.dpatch) + (Closes: #443594) + * This time fix really the usb autosuspend issue. (Closes: #444817) + * Add a Homepage field to control. + + -- Patrick Winnertz Sun, 16 Dec 2007 23:33:32 +0100 + +powertop (1.9-1) unstable; urgency=low + + * Packaging new upstream release. (Closes: #451370) + * Fix the wrong implementation of usb autosuspend (Closes: #444817) + + -- Patrick Winnertz Thu, 22 Nov 2007 13:17:38 +0100 + +powertop (1.8-1) unstable; urgency=low + + * Packaging new upstream release. + * Correct the dependency to laptop-mode-tools. (Closes: #438616) + * Correct the command line syntax of hal-disable-polling (Closes: #435882) + * Allow powertop to build on all archs since some information are still + there (wakeup counts). + + -- Patrick Winnertz Mon, 20 Aug 2007 22:23:53 +0200 + +powertop (1.7~svn-r227-3) unstable; urgency=low + + * debian/control: + + Changed the `arch" field to: `i386 amd64 ia64'. (Closes: #435972) + * debian/copyright: + + Fixed the license related issue, updated to just GPL2 including the + license address to `/usr/share/common-licenses/GPL-2'. (Closes: #436367) + + -- Jose Luis Rivas Thu, 16 Aug 2007 23:01:09 -0400 + +powertop (1.7~svn-r227-2) unstable; urgency=low + + * Thanks to Krzysztof Burghardt for the new package release, but + remove him as co-maintainer, as he is none after all + + -- Patrick Winnertz Fri, 13 Jul 2007 20:39:21 +0200 + +powertop (1.7~svn-r227-1) unstable; urgency=low + + * New co-maintainer + * New upstream (closes: #429305, #430035, #427345) + * Moved binary to /usr/sbin as it need to be run by root (closes: #427548) + * debian/copyright: + + changed a bit to fulfill standard look + + -- Krzysztof Burghardt Sat, 23 Jun 2007 20:30:02 +0200 + +powertop (1.5-2) unstable; urgency=low + + * debian/control: + + Two leading spaces for Homepage (Closes: #426606) + * debian/changelog: + + Fixed typo on "Cooperation" now "Corporation" (Closes: #426605) + + -- Jose Luis Rivas Wed, 30 May 2007 08:46:08 -0400 + +powertop (1.5-1) unstable; urgency=low + + * New upstream release available (Closes: #426507) + * Adding Build-Depends: libncursesw5-dev since powertop fails to build without it. + * Modified debian/copyright: + - added (c) 2007 Intel Corporation + - powertop is licensed under GPL v2 (added v2) + + -- Patrick Winnertz Tue, 29 May 2007 13:43:06 +0200 + +powertop (1.4-2) unstable; urgency=low + + [ Jose Luis Rivas ] + * debian/control: + + Fixed the Homepage field (Closes: #426205) + + Modified the uploader name to "Jose Luis Rivas" + + [ Patrick Winnertz ] + * Fixed FTBFS, by depending on libncurses5-dev (Closes: #426235) + * Uses $(CURDIR) instead of `pwd` in rules. + * Upload sponsored by Petter Reinholdtsen + + -- Patrick Winnertz Sun, 27 May 2007 17:59:38 +0200 + +powertop (1.4-1) unstable; urgency=low + + * New upstream release + * Now powertop uses the full width of a terminal. (Fixed by upstream) + (Closes: #423735) + * Changed the destdir in debian/rules so that the locale files are installed correctly + to debian/powertop/usr/share/locale/: + - DESTDIR=debian/powertop --> DESTDIR=`pwd`/debian/powertop + * Upload sponsored by Petter Reinholdtsen + + -- Patrick Winnertz Sat, 26 May 2007 17:24:27 +0200 + +powertop (1.3-1) unstable; urgency=low + + * New upstream release (Closes: #425498) + * Suggests cpufrequtils (Closes: #423986) + * Clean up debian/rules: + - removes simple-patchsys.mk since it not used + - remove the installation of the manpage since we now use debian/manpages + ( Thanks to Jose ) + + -- Patrick Winnertz Fri, 25 May 2007 16:48:52 +0200 + +powertop (1.2-1) unstable; urgency=low + + * New upstream release available. + * Took the package from pere, and added me as Maintainer and Jose Luis + Rivas Contreras into the Uploader field. + * Removed the manpage from the debian-dir since it is now upstream and adjusted + the install command in debian/rules. + * Removed the makefile patch, since it is now upstream + + -- Patrick Winnertz Wed, 16 May 2007 12:35:58 +0200 + +powertop (1.1-3) unstable; urgency=low + + * Add watch file written by Ralf Meyer for Ubuntu. Removed + most of the examples. + + -- Petter Reinholdtsen Mon, 14 May 2007 08:08:24 +0200 + +powertop (1.1-2) unstable; urgency=low + + * Add powertop(1) manual page. Written by Carlo + Segre. (Closes: #423607) + + -- Petter Reinholdtsen Sun, 13 May 2007 21:13:00 +0200 + +powertop (1.1-1) unstable; urgency=low + + * New upstream release. + * Rewrite debian/rules to use cdbs and simple-patchsys. + * Change section from x11 to utils. It make more sense + for this tool. + * Rewrite 10_makefile.patch as most of the changes are + included upstream. + + -- Petter Reinholdtsen Sun, 13 May 2007 12:10:15 +0200 + +powertop (1.0-1) unstable; urgency=low + + * Initial release (Closes: #423504) + + -- Petter Reinholdtsen Sat, 12 May 2007 23:13:05 +0200 + --- powertop-1.13.orig/debian/copyright +++ powertop-1.13/debian/copyright @@ -0,0 +1,33 @@ +This package was debianized by Petter Reinholdtsen on +Sat May 12 23:22:21 CEST 2007. + +It was downloaded from http://www.linuxpowertop.org/download/ + +Upstream Author: + + Arjan van de Ven + +Copyright: + + Copyright 2007 Intel Corporation + +License: + + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation version 2 of the License. + + This package 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 package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL-2'. + +The Debian packaging is copyrighted 2007, Petter Reinholdtsen and +is licensed under the GPL, see above. --- powertop-1.13.orig/debian/manpages +++ powertop-1.13/debian/manpages @@ -0,0 +1 @@ +powertop.8 --- powertop-1.13.orig/debian/source/format +++ powertop-1.13/debian/source/format @@ -0,0 +1 @@ +1.0