summaryrefslogtreecommitdiff
path: root/src/linux/up-device-supply.c
AgeCommit message (Collapse)AuthorFilesLines
2014-10-08all: convert value from g_get_real_time() to secondsEvangelos Foutras1-1/+1
Commit 5ddfe0d (all: Use g_get_real_time() when possible) replaced calls to g_get_current_time() with g_get_real_time(), however, we also need to convert the return value from microseconds to seconds. Signed-off-by: Richard Hughes <richard@hughsie.com>
2014-09-24all: Use g_get_real_time() when possibleBastien Nocera1-5/+2
Instead of a call to g_get_current_time().
2013-10-28linux: Use daemon poll for batteries tooBastien Nocera1-73/+23
This has 2 effects: - we never stop polling (we used to stop polling when the battery was marked as fully-charged, but that can happen when the battery is discharging too) - when in an unknown state, we will poll through the daemon, and through our unknown poll. This isn't a problem as there'll another 115 seconds of wait until we get to poll through the daemon again.
2013-10-28linux: Switch non-battery devices to use the new daemon pollBastien Nocera1-2/+22
Next up is doing this for batteries, which need to switch between a normal/slow poll to a faster one when the battery state is unknown.
2013-10-26daemon: Better timeout source namingBastien Nocera1-6/+24
Matching the work done in glib, gtk+, etc. This also differentiates the unknown and normal timeouts in the Linux power supply driver.
2013-10-26linux: Add NoPollBatteries configuration optionBastien Nocera1-3/+13
For system integrators. If your firmware is helpful to user space and automatically sends out uevent when the battery level changes (rather than just the battery state) as on most machines, you can enable "NoPollBatteries" in the configuration option, and reduce power consumption from UPower and its listeners.
2013-10-26linux: Split up battery and device refreshBastien Nocera1-7/+7
In up_device_supply_refresh().
2013-10-26linux: Move poll disable to another functionBastien Nocera1-4/+12
2013-10-26linux: Only disable timeouts if ever setBastien Nocera1-5/+5
We cannot ever set the refresh timeout when we have a power line device, so don't try and remove it there.
2013-10-26linux: Poll for unknown state like the daemon didBastien Nocera1-2/+2
5 times, with 1 second timeouts, instead of 30 times, with 2 seconds timeouts.
2013-10-26linux: Fix the "unknown state" heavy pollBastien Nocera1-9/+15
It was never actually setup, as the fallback state was used to check whether we should use poll or not.
2013-10-22linux: Clamp percentage for overfull batteriesMartin Pitt1-0/+4
Some batteries report energy > energy_full and a percentage ("capacity" attribute) > 100%. Clamp these within 0 and 100% for both plausibility as well as to avoid setting an out-of-range property which would then become 0%. https://launchpad.net/bugs/1240673
2013-10-18daemon: Fix typos in commentsBastien Nocera1-1/+1
2013-10-18linux: Mark devices with 100% battery as fullBastien Nocera1-0/+5
2013-10-18linux: Fix Bluetooth devices appearing with 0% batteryBastien Nocera1-1/+7
When switching off Bluetooth devices, and before they timeout, we won't be able to read the battery percentage, so don't overwrite the previous value with "0%", but set the state to unknown instead. https://bugs.freedesktop.org/show_bug.cgi?id=70325
2013-10-18linux: Use up_device_supply_get_string()Bastien Nocera1-5/+6
In up_device_supply_get_state()
2013-10-18linux: Add a simpler, quicker path for devicesBastien Nocera1-1/+66
When refreshing the state of device batteries, no need to get data that won't be there anyway, such as voltage, temperature, or consumption rate. This avoids warnings about voltage being unknown for devices, and cuts down on the properties churn.
2013-10-18linux: Split off device state retrievalBastien Nocera1-20/+31
We're going to be reusing this elsewhere.
2013-10-18linux: Ignore ACs coming from devicesBastien Nocera1-0/+7
We already have enough information on the device battery. This avoids having a device for the wacom AC which we won't use.
2013-10-18linux: Remove incorrect statementBastien Nocera1-1/+0
Not all "UpDeviceSupply" actually supply power to the computer.
2013-10-14daemon: Require newer GLibBastien Nocera1-4/+1
And remove ifdef's.
2013-10-14daemon: Replace "on-low-battery" propertyBastien Nocera1-31/+0
With "warning-level" property.
2013-10-14daemon: Remove unneeded reset of priv struct membersBastien Nocera1-3/+0
It's already done by GObject.
2013-10-14Remove obsolete battery recall propertiesBastien Nocera1-13/+0
The recalls for that broken batch of Sony batteries dates back from 2006. All the batteries that could have been recalled have now been recalled, and somebody particularly interested in supporting them can match the batteries using the old rules file, in a user session or a separate daemon.
2013-10-14linux: Don't print a warning if the status sysfs attr is missingBastien Nocera1-1/+2
This is the case for some devices like the Wacom wireless (Bluetooth) tablets, and shouldn't produce a warning.
2013-10-14linux: Don't guess discharging state for devicesBastien Nocera1-1/+1
If the device state is unknown, don't guess based on the laptop's power supplies (battery/power line) as it might not be charging from there. https://bugs.freedesktop.org/show_bug.cgi?id=70321#c1
2013-09-06linux: Detect the battery of bluetooth input devicesShih-Yuan Lee (FourDollars)1-1/+50
Check the input subdevices of the bluetooth parent device of a battery, if present. If there is mouse* input child device, is a mouse battery; otherwise, it is a keyboard battery. This also fixes the PowerSupply attribute for these to be false, as the batteries of wireless input devices don't power the system. https://launchpad.net/bugs/1153488 Signed-Off-By: Martin Pitt <martin.pitt@ubuntu.com>
2013-09-03linux: Allow valid UTF-8 encoded stringShih-Yuan Lee (FourDollars)1-0/+3
Signed-Off-By: Martin Pitt <martin.pitt@ubuntu.com>
2013-09-02linux: Only one warning if no valid voltage foundTimothée Ravier1-3/+12
Avoid filling the logs with repeated warning saying that no correct voltage value was found for a power device. Improves the situation with bugs https://bugzilla.redhat.com/show_bug.cgi?id=847874 and https://bugzilla.redhat.com/show_bug.cgi?id=863524 Signed-off-by: Timothée Ravier <tim@siosm.fr> Signed-off-by: Martin Pitt <martinpitt@gnome.org>
2013-08-26Linux: More explicit warning when no voltage foundTimothée Ravier1-1/+1
Add device full path in warning if retrieving design voltage fails in up_device_supply_get_design_voltage(). Also helps diagnose bugs https://bugzilla.redhat.com/show_bug.cgi?id=847874 and https://bugzilla.redhat.com/show_bug.cgi?id=863524 Signed-off-by: Martin Pitt <martinpitt@gnome.org>
2013-08-26Linux: Fix warning in up_device_supply_get_design_voltageTimothée Ravier1-1/+1
This avoids filling the logs with the unnecessary warning line: GLib-CRITICAL **: g_ascii_strcasecmp: assertion `s1 != NULL' failed as seen in https://bugzilla.redhat.com/show_bug.cgi?id=847874 and https://bugzilla.redhat.com/show_bug.cgi?id=863524 Signed-off-by: Martin Pitt <martinpitt@gnome.org>
2013-08-23Add temperature property for batteriesSeth Forshee1-0/+6
Linux's power_supply class supports a temperature attribute, which is supported by many battery drivers. Add a new property to export this information and support this property in Linux. https://bugs.freedesktop.org/show_bug.cgi?id=68338 Signed-off-by: Seth Forshee <seth.forshee@canonical.com> Signed-off-by: Martin Pitt <martinpitt@gnome.org>
2013-08-23linux: Fix batteries which report capacity, but not energy/chargeMartin Pitt1-8/+6
Many Android devices only export charge_full and capacity, but not charge_now or energy_now. In that case, directly read the percentage (from the capacity attribute) and calculate current energy from that. Thanks to Seth Forshee for the original patch! https://bugs.freedesktop.org/show_bug.cgi?id=68337
2013-01-31linux: Bump maximum accepted "time to empty" to 10 daysMartin Pitt1-2/+2
In the days of low-power ARM devices and large laptop batteries, imposing a 20 hour plausibility limit on "time to full" is not appropriate any more. Bump it to 240 hours to still keep a plausibility check against "factor 1000" errors. https://bugs.freedesktop.org/show_bug.cgi?id=60110
2013-01-31linux: Fix batteries which report current energy but full chargeAlex Hornung1-1/+1
The condition should be for energy_full, not energy, since we aim to find some way of finding energy_full and energy_full_design irrespective of the way we find energy. https://bugs.freedesktop.org/show_bug.cgi?id=60104 Signed-off-by: Alex Hornung <alex@alexhornung.com>
2013-01-29Fix two memory leaksColin Watson1-1/+2
up_device_supply_get_design_voltage(): up_device_supply_get_string() returns a newly allocated copy. up_history_finalize(): Forgot to free history->priv->dir https://bugs.freedesktop.org/show_bug.cgi?id=60019
2012-06-18linux: Remove obsolete check for magicmouse_ and duplicated wacom_ checksDaniel Nicoletti1-4/+1
Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-06-18linux: Don't allow non-power-supply devices to set the OnBattery propertyDaniel Nicoletti1-0/+4
Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-06-14Fix wrong PowerSupply property for devices without a scope sysfs attributeMartin Pitt1-2/+2
Fix NULL pointer comparison in up_device_supply_coldplug(). This caused (lt-upowerd:5754): GLib-CRITICAL **: g_ascii_strcasecmp: assertion `s1 != NULL' failed when a device does not have a "scope" sysfs attribute, and erroneously considering that device to not power the system. https://launchpad.net/bugs/1012578
2012-05-30linux: Treat the battery state 'not charging' as PENDING_CHARGERichard Hughes1-0/+2
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=826215
2012-04-27Correct the cap on the energy rateGary Ching-Pang Lin1-1/+1
Signed-off-by: Richard Hughes <richard@hughsie.com>
2012-04-18Never detect HID devices with batteries as power suppliesRichard Hughes1-2/+12
Some HID devices with batteries (like bluetooth keyboards) have been creating power supply devices in sysfs since Linux 3.3. UPower thinks that they are system devices and shuts down the system if they get low. This is bad. This is fixed in Linux 3.4, where there is a new 'scope' file that defines if the device is powering the system. Helpfully ACPI batteries don't populate the scope value, but soon will. Add support for the scope attribute now, and default to system devices if it's missing. Note, you need to be running a 3.4 kernel or a 3.3 with the patch backported for this to work. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=806295
2011-12-03upower: Handle Linux power supplies not exporting a present propertyHeiko Stübner1-1/+6
According to Anton Vorontsov (Linux power supply maintainer) power supplies should not export a present property when they are not hotpluggable and users of the properties should handle supplies without present-property as always present. This patch implements this feature using an additional sysfs_file_exists call before sysfs_get_bool. Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-11-29trivial: USB devices are assumed to be 5VRichard Hughes1-0/+9
2011-11-29trivial: fix the name of the percentage fileRichard Hughes1-1/+1
2011-11-29Don't assert when the power_supply device type is usbRichard Hughes1-4/+1
2011-11-29Move the wacom hack to allow us to support other types of USB deviceRichard Hughes1-26/+17
2011-11-29If a power-supply device doesn't report charge or energy, try to read the ↵Richard Hughes1-1/+8
percentage
2011-10-19Use linear regression to get better predicted battery timesLeonardo Robol1-24/+99
For hardware that has no rate data we use the differences in charge over a time period to work out the effective rate. Using linear regression this estimation is much more realistic. To do this, introduce a simple circular buffer and use an index to calculate the rate on each update. Signed-off-by: Richard Hughes <richard@hughsie.com>
2011-07-19Hardcode wacom battery devices as not power-supply devicesRichard Hughes1-3/+31
We'll switch to a kernel property when the power_supply interface is fixed.