[CCing powertop mailing list]
On Mon, Jul 21, 2008 at 09:13:07AM +0400, Alexey Starikovskiy wrote:
> Hi Michal,
Hi Alexey,
>
> Battery can return either energy (voltage*charge) or just charge.
> In your case it returns only charge. You need to multiply by voltage to
> get energy.
Thanks for your information. I was confused that both (CHARGE_ and
ENERGY_) cases were handled by the same value but didn't realize that
the value itself may come from different source.
Based on your suggestion, I am attaching patch for current powertop
which reads charge_now if energy_now is not present.
I am not sure whether this is correct, testing on my laptop shows weird
values for current consumption:
Power usage (ACPI estimate): 1.4W (40.7 hours) (long term: 24.4W,/2.3h)
Even long term value seems to not correspond with the value exported by
KPowersafe which shows 3:18 at this moment.
Is there something wrong in the patch or it is just my battery exporting
bad values? Current values from sys are attached too.
>
> Regards,
> Alex.
>
>
> Michal Hocko wrote:
>> Hi,
>>
>> I am trying to use powertop on my computer, but I am not able to get
>> power consumption (powertop complains with "no ACPI power usage estimate
>> available").
>>
>> After powertop code reading it seems that problem is that it expects
>> %subj file to be present what is not a case for my Fujitsu Siemens
>> Lifebook S71110 notbebook:
>>
>> /sys/class/power_supply/CMB1 $ find -type f
>> ./uevent
>> ./power/wakeup
>> ./type
>> ./status
>> ./present
>> ./technology
>> ./voltage_min_design
>> ./voltage_now
>> ./current_now
>> ./charge_full_design
>> ./charge_full
>> ./charge_now
>> ./model_name
>> ./manufacturer
>> ./serial_number
>> ./alarm
>>
>> I can see only charge_* files but no energy_* one.
>>
>> Documentation/power/power_supply_class.txt notes that ENERGY_* and
>> CHARGE_* attributes shouldn't be mixed because of different measurements
>> units.
>>
>> However, It looks like battery module doesn't make any difference when
>> reading values for ENERGY_ and CHARGE_ attributes:
>> drivers/acpi/battery.c:
>> acpi_battery_get_property
>> [...]
>> case POWER_SUPPLY_PROP_CHARGE_NOW:
>> case POWER_SUPPLY_PROP_ENERGY_NOW:
>> val->intval = battery->capacity_now * 1000;
>> break;
>> [...]
>>
>> So the question is, why this file is not exported when the module can
>> provide its value?
>>
>> If this is correct and it somehow depends on BIOS, how should powertop
>> handle such a case when only charge_* files are available?
>>
>> I am using Debian distribution 2.6.25 kernel (but the same issue is
>> present also in Vanilla 2.6.26 kernel).
>>
>> Let me know, if you need some more information.
>>
>> Thanks for any hint and
>> best regards
--
Michal Hocko
./uevent
PHYSDEVPATH=/devices/LNXSYSTM:00/device:00/PNP0C0A:00
PHYSDEVBUS=acpi
PHYSDEVDRIVER=battery
POWER_SUPPLY_NAME=CMB1
POWER_SUPPLY_TYPE=Battery
POWER_SUPPLY_STATUS=Discharging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=10800000
POWER_SUPPLY_VOLTAGE_NOW=11900000
POWER_SUPPLY_CURRENT_NOW=1609000
POWER_SUPPLY_CHARGE_FULL_DESIGN=5200000
POWER_SUPPLY_CHARGE_FULL=4996000
POWER_SUPPLY_CHARGE_NOW=4600000
POWER_SUPPLY_MODEL_NAME=CP293530
POWER_SUPPLY_MANUFACTURER=Fujitsu
POWER_SUPPLY_SERIAL_NUMBER=1
./power/wakeup
./type
Battery
./status
Discharging
./present
1
./technology
Li-ion
./voltage_min_design
10800000
./voltage_now
11900000
./current_now
1609000
./charge_full_design
5200000
./charge_full
4996000
./charge_now
4600000
./model_name
CP293530
./manufacturer
Fujitsu
./serial_number
1
./alarm
0
From: [EMAIL PROTECTED]
Subject: [PATCH] use charge_now when energy_now is not present
Some batteries (like one in the Futjitsu Siemens Lifebook S71110) don't
export energy_now attribute and exports only change_now in the power_supply
sys directory.
However, we can use this value when it is multiplied by current voltage.
Signed-off-by: Michal Hocko <[EMAIL PROTECTED]>
--- a/powertop.c 2008-07-21 10:35:10.000000000 -0600
+++ b/powertop.c 2008-07-21 10:36:03.000000000 -0600
@@ -630,11 +630,19 @@ void print_battery_sysfs(void)
sprintf(filename, "/sys/class/power_supply/%s/energy_now", dirent->d_name);
file = fopen(filename, "r");
- if (!file)
- continue;
+ watts_left = 1;
+ if (!file) {
+ sprintf(filename, "/sys/class/power_supply/%s/charge_now", dirent->d_name);
+ file = fopen(filename, "r");
+ if (!file)
+ continue;
+
+ /* W = A * V */
+ watts_left = voltage;
+ }
memset(line, 0, 1024);
if (fgets(line, 1024, file) != NULL) {
- watts_left = strtoull(line, NULL, 10) / 1000000.0;
+ watts_left *= strtoull(line, NULL, 10) / 1000000.0;
}
fclose(file);
_______________________________________________
Power mailing list
[email protected]
http://www.bughost.org/mailman/listinfo/power