mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-04-20 00:10:43 +02:00
Support the power_now sysfs attribute to get time remaining on new kernels
The kernel has removed the insanity of providing current_now in either (and unspecified) units of uVh or uWh and instead provides power_now for the power rate value. Related commits: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=b137b9942a07843c64a934cfdb7d43155e507e13 http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=7faa144a518c456e2057918f030f50100144ccc6 Thanks to Florian Eitel for the initial patch.
This commit is contained in:
parent
2dcde5a1c8
commit
2af7a6e091
1 changed files with 13 additions and 9 deletions
|
|
@ -554,16 +554,20 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply)
|
|||
supply->priv->unknown_retries = 0;
|
||||
}
|
||||
|
||||
/* get rate; it seems odd as it's either in uVh or uWh */
|
||||
energy_rate = fabs (sysfs_get_double (native_path, "current_now") / 1000000.0);
|
||||
/* this is the new value in mWh */
|
||||
energy_rate = fabs (sysfs_get_double (native_path, "power_now") / 1000000.0);
|
||||
if (energy_rate == 0) {
|
||||
/* get the old rate, rate; which is either in uVh or uWh */
|
||||
energy_rate = fabs (sysfs_get_double (native_path, "current_now") / 1000000.0);
|
||||
|
||||
/* convert charge to energy */
|
||||
if (energy == 0) {
|
||||
energy = sysfs_get_double (native_path, "charge_now") / 1000000.0;
|
||||
if (energy == 0)
|
||||
energy = sysfs_get_double (native_path, "charge_avg") / 1000000.0;
|
||||
energy *= voltage_design;
|
||||
energy_rate *= voltage_design;
|
||||
/* convert charge to energy */
|
||||
if (energy == 0) {
|
||||
energy = sysfs_get_double (native_path, "charge_now") / 1000000.0;
|
||||
if (energy == 0)
|
||||
energy = sysfs_get_double (native_path, "charge_avg") / 1000000.0;
|
||||
energy *= voltage_design;
|
||||
energy_rate *= voltage_design;
|
||||
}
|
||||
}
|
||||
|
||||
/* some batteries don't update last_full attribute */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue