diff options
author | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2010-11-02 18:49:08 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2010-11-02 20:45:41 +0530 |
commit | 0dcd2963d602b554d815f1c80e9a47514f89d660 (patch) | |
tree | 75a816ae4b14055f7ce8bf882b84ac6789e7a612 /sys-power/upower/files/upower-dell-samsung-sdi-battery-quirk.patch | |
parent | Add app-text/tesseract (diff) | |
download | nirbheek-0dcd2963d602b554d815f1c80e9a47514f89d660.tar.gz nirbheek-0dcd2963d602b554d815f1c80e9a47514f89d660.tar.bz2 nirbheek-0dcd2963d602b554d815f1c80e9a47514f89d660.zip |
sys-power/upower: fix bad battery state when fully-charged
* Some Dell laptop batteries set their state as "Discharging" when they finish
charging
* Use the power supply status and the battery level to guess the correct state
* Upstream bug: https://bugs.freedesktop.org/show_bug.cgi?id=31196
Diffstat (limited to 'sys-power/upower/files/upower-dell-samsung-sdi-battery-quirk.patch')
-rw-r--r-- | sys-power/upower/files/upower-dell-samsung-sdi-battery-quirk.patch | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/sys-power/upower/files/upower-dell-samsung-sdi-battery-quirk.patch b/sys-power/upower/files/upower-dell-samsung-sdi-battery-quirk.patch new file mode 100644 index 0000000..9781dbf --- /dev/null +++ b/sys-power/upower/files/upower-dell-samsung-sdi-battery-quirk.patch @@ -0,0 +1,76 @@ +Once full, some Dell laptop batteries show battery state as "fully-charged" for +a second, and then set battery state as "Discharging". However, the "on-battery" +status is correct. Try to do some guesswork for this case. + +Was observed with the following battery: + +vendor: SAMSUNG SDI +model: DELL U600P04 +serial: 0000 +technology: lithium-ion + +--- +--- src/linux/up-device-supply.c ++++ src/linux/up-device-supply.c +@@ -405,6 +405,9 @@ + UpDeviceState old_state; + UpDeviceState state; + UpDevice *device = UP_DEVICE (supply); ++ UpDevice *device_tmp; ++ UpDeviceKind type; ++ GPtrArray *devices; + const gchar *native_path; + GUdevDevice *native; + gboolean is_present; +@@ -425,7 +428,9 @@ + const gchar *recall_url = NULL; + UpDaemon *daemon; + gboolean on_battery; ++ gboolean online; + guint battery_count; ++ guint i; + + native = G_UDEV_DEVICE (up_device_get_native (device)); + native_path = g_udev_device_get_sysfs_path (native); +@@ -610,6 +615,41 @@ + state = UP_DEVICE_STATE_FULLY_CHARGED; + } + ++ /* some batteries show themselves as 'discharging' once they're full */ ++ if (state == UP_DEVICE_STATE_DISCHARGING && percentage == 100.0f) { ++ state = UP_DEVICE_STATE_FULLY_CHARGED; ++ daemon = up_device_get_daemon (device); ++ /* get states of AC power supplies */ ++ devices = up_device_list_get_array (up_daemon_get_device_list(daemon)); ++ for (i=0; i<devices->len; i++) { ++ device_tmp = (UpDevice *) g_ptr_array_index (devices, i); ++ g_object_get (device_tmp, ++ "type", &type, ++ NULL); ++ if (type != UP_DEVICE_KIND_LINE_POWER) ++ continue; ++ ret = up_device_supply_get_online (device_tmp, &online); ++ if (!ret) ++ continue; ++ ++ /* print what we're trying */ ++ egg_debug ("guessing battery state using power supply status:%i", ++ online); ++ ++ /* If any of the power supplies is not online, ++ * assume it's discharging, and break */ ++ if (!online) { ++ state = UP_DEVICE_STATE_DISCHARGING; ++ break; ++ } ++ } ++ /* print what we did */ ++ egg_debug ("guessed battery state as '%s' using power supply status", ++ up_device_state_to_string (state)); ++ ++ g_ptr_array_unref (devices); ++ } ++ + /* the battery isn't charging or discharging, it's just + * sitting there half full doing nothing: try to guess a state */ + if (state == UP_DEVICE_STATE_UNKNOWN) { |