Add collection of average power during measurement.

Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
Add option to specify workload to run during measurement.

Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
update patch for workload measurements to fix reporting and last measurement options
Add an option to suppress output to the terminal.  This allows you to
lose unwanted output when calling powertop from a script.

Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
Change report naming convention

If a single iteration/workload is being run use the filename command
line argument as the complete basename for the report file.  The
behavior for multiple iterations is unchanged.

This enables scripts calling powertop to know the filename of the
report for any post processing of the report.

Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
Use printf, not sprintf, to print messages to stdout.

This undos the last printf->sprintf change from 8fd54ace.

Signed-off-by: Magnus Fromreide <magfr@lysator.liu.se>
prevent jump on uninitialized value

workload is getting 'initialized' with stack garbage,
so later conditional check of !workload[0] in report()
is invalid.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
remove -Werror from AM_INIT_AUTOMAKE

While this is nice while developing, it may cause
various problems with distributed tarballs.

A new automake version could add a warning, causing errors for distributions
and users, who might need to patch configure.ac and thus run autoreconf.

For example, we hit an error where a third party package (gettext) uses
functionality (AM_PROG_MKDIR_P) which is deprecated in newer automake versions(1.12.1),
causing the powertop build to fail.

Since the problem lies elsewhere, it is stupid to fail for this while building powertop
Wrong common field name in GFX Wakeups event

Here is formatted version of the patch:

 From 23362fa0f7bbfd0497a8ccbb9d06a4520eae8057 Mon Sep 17 00:00:00 2001
From: Igor Zhbanov<i.zhbanov@samsung.com>
Date: Wed, 11 Jul 2012 12:30:27 +0400
Subject: [PATCH] Wrong common field name in GFX Wakeups event

I have found that PowerTOP doesn't displays values in "GFX Wakeups/s" column.
It is because of wrong event field name the handle_trace_point() method
expects to find in a trace event.
Device list sort function bug

So here is the formatted version:

 From 5d284137a6035bab65717fbacd98423b96d862cf Mon Sep 17 00:00:00 2001
From: Igor Zhbanov<i.zhbanov@samsung.com>
Date: Wed, 11 Jul 2012 12:08:21 +0400
Subject: [PATCH] Device list sort function bug

Sometimes PowerTOP dies with a Segmentation Fault while generating
the report. Little investigation shown that it dies while sorting
the device list. The problem is that comparison function devlist_sort
is incorrect.

The function should return true if first argument "preceeds" second.
But when strcmp() is used, it can return -1, 0 and 1. So both -1 and 1
values are silently converted to true, which is wrong. It confuses the sort()
function and it crosses boundary of array.
update patch issue
Display all P-states in HTML-report

This is the formatted version of the patch:

 From 66d0f194250d94afcf83eb7712af6f50c6ad8ec4 Mon Sep 17 00:00:00 2001
From: Igor Zhbanov<i.zhbanov@samsung.com>
Date: Wed, 11 Jul 2012 12:35:31 +0400
Subject: [PATCH] Display all P-states in HTML-report

On Arm processors there are more than 10 P-states. On my device there are 12
p-states with different frequency. But PowerTOP displays only 10. And it
doesn't display states (11 and 12) where the phone spends most of the time.

I suppose that was because of console mode of PowerTOP, when there are limited
number of lines on the console. But in the case of HTML-report this should
not be a problem.

This patch that counts the number of found P-states and displays all of them.

The same issue may affect the function report_display_cpu_cstates()
but I'm not sure that CPUs with more than 10 C-states exists.

The same code is in the function impl_w_display_cpu_states(), but that
function is used in console mode only where lines limit is reasonable.
Fix handling of /proc/cpuinfo for non x86 architectures

Not all architectures include lines with "vendor_id\t" or
"processor\t". ARM Linux without SMP support includes
neither of these two entries. With SMP support, there are
"processor\t" entries for each CPU.

Set vendor to an empty string initially, so there is a default value.

Assume CPU id 0 when no number was set while encountering the first
"bogomips\t" line. If there are more such lines without a correct
number, only the first CPU is handled. This should not be needed
for ARM, but makes the code more robust because it avoids calling
handle_one_cpu twice with number == 0.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
ccstoh: Don't return success if something went wrong

exit(0) is the same as returning EXIT_SUCCESS which is a bad
idea after a severe failure. It will for example result in
wrong behaviour of make (make won't stop after such failures).

Returning EXIT_FAILURE fixes this.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Fix out-of-tree builds

Out-of-tree builds are a very useful feature which should be supported
by all programs which use GNU automake and the configure / make build.

For powertop, only a very small fix was needed to make it work.
Without that fix, powertop.css is not found when a build is not
started from the source tree, so csstoh fails and creates no css.h.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Remove unneded zlib dependency

Remove unneded zlib dependency from configure.ac
Get rid of ncurses' TRUE and FALSE

Get rid of TRUE and FALSE ncurses' defines used for boolean variables
initialization. This fix also helps build without ncurses support.
conditionally disable pci if not supported

disable pci if not supported by host platform. When
libpci is not found, define a macro which will be
used for conditional compilation.

Signed-off-by: Rajagopal Venkat <rajagopal.venkat@linaro.org>
For systems with pci you will want libpci, but for systems that do not have pci you will not.
libpci has been made an optional lib, but for thoes who have pci, a warning has been added.
this warning is to let people know that PowerTOP was configured with pci support.
conditionally disable pci if not supported

disable pci if not supported by host platform. When
libpci is not found, define a macro which will be
used for conditional compilation.

Signed-off-by: Rajagopal Venkat <rajagopal.venkat@linaro.org>