diff options
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 | 78 |
1 files changed, 78 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..24fb764 --- /dev/null +++ b/sys-power/upower/files/upower-dell-samsung-sdi-battery-quirk.patch @@ -0,0 +1,78 @@ +From 7849ca66af7f74bfdba968e979c4596c9e99ff3d Mon Sep 17 00:00:00 2001 +From: Nirbheek Chauhan <nirbheek@gentoo.org> +Date: Sub, 29 May 2011 15:43:22 +0530 +Subject: [PATCH] Add Dell laptop battery always-discharging quirk + +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 + +https://bugs.freedesktop.org/show_bug.cgi?id=31196 +--- + src/linux/up-device-supply.c | 37 ++++++++++++++++++++++++++++++++++++++++ + 1 files changed, 37 insertions(+), 0 deletions(-) + +diff --git a/src/linux/up-device-supply.c b/src/linux/up-device-supply.c +index 341f5df..4294e04 100644 +--- a/src/linux/up-device-supply.c ++++ b/src/linux/up-device-supply.c +@@ -402,6 +402,8 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply) + UpDeviceState old_state; + UpDeviceState state; + UpDevice *device = UP_DEVICE (supply); ++ UpDevice *device_tmp; ++ UpDeviceKind type; + const gchar *native_path; + GUdevDevice *native; + gboolean is_present; +@@ -599,6 +604,40 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply) + if (percentage > 100.0f) + percentage = 100.0f; + } ++ /* 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 */ ++ g_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 */ ++ g_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 */ +-- +1.7.2.2 + |