gnome-power-manager r2862 - in trunk: . src



Author: rhughes
Date: Tue Aug  5 12:59:07 2008
New Revision: 2862
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=2862&view=rev

Log:
2008-08-05  atthew Garrett  <mjg59 redhat com>

* src/gpm-cell-unit.c: (gpm_cell_unit_init):
* src/gpm-cell-unit.h:
* src/gpm-cell.c: (gpm_cell_refresh_hal_all):
The ACPI spec has the following:

'Notice that when the battery is a primary battery (a non-rechargeable
battery such as an Alkaline-Manganese battery) and cannot provide
accurate information about the battery to use in the calculation of the
remaining battery life, the Control Method Battery can report the
percentage directly to OS. It does so by reporting the Last Full
Charged Capacity = 100 and BatteryPresentRate=0xFFFFFFFF.
This means that Battery Remaining Capacity directly reports the
battery's remaining capacity [%] as a value in the range 0 through 100'

The Eee behaves like this despite the fact that its battery is
rechargeable, so ends up triggering the 'Broken battery' warning in
g-p-m. This patch adds support for avoiding this case.


Modified:
   trunk/ChangeLog
   trunk/src/gpm-cell-unit.c
   trunk/src/gpm-cell-unit.h
   trunk/src/gpm-cell.c

Modified: trunk/src/gpm-cell-unit.c
==============================================================================
--- trunk/src/gpm-cell-unit.c	(original)
+++ trunk/src/gpm-cell-unit.c	Tue Aug  5 12:59:07 2008
@@ -50,6 +50,7 @@
 	unit->is_present = FALSE;
 	unit->is_charging = FALSE;
 	unit->is_discharging = FALSE;
+	unit->reports_percentage = FALSE;
 
 	return TRUE;
 }

Modified: trunk/src/gpm-cell-unit.h
==============================================================================
--- trunk/src/gpm-cell-unit.h	(original)
+++ trunk/src/gpm-cell-unit.h	Tue Aug  5 12:59:07 2008
@@ -57,6 +57,7 @@
 	gboolean	 is_present;
 	gboolean	 is_charging;
 	gboolean	 is_discharging;
+	gboolean         reports_percentage;
 } GpmCellUnit;
 
 gboolean	 gpm_cell_unit_init		(GpmCellUnit	*unit);

Modified: trunk/src/gpm-cell.c
==============================================================================
--- trunk/src/gpm-cell.c	(original)
+++ trunk/src/gpm-cell.c	Tue Aug  5 12:59:07 2008
@@ -144,6 +144,15 @@
 			gpm_warning ("sanity checking rate from %i to 0", unit->rate);
 			unit->rate = 0;
 		}
+		/* The ACPI spec only allows this for primary cells, but in the real
+		   world we also see it for rechargeables. Sigh */
+		if (unit->rate == 0) {
+			guint raw_last_charge;
+			hal_gdevice_get_uint (device, "battery.reporting.last_full",
+					      &raw_last_charge, NULL);
+			if (raw_last_charge == 100)
+				unit->reports_percentage = TRUE;
+		}
 	}
 
 	/* sanity check that charge_level.percentage exists (if it should) */
@@ -181,7 +190,7 @@
 						   "%i to 0", unit->capacity);
 					unit->capacity = 0;
 				}
-				if (unit->capacity < 50) {
+				if (unit->capacity < 50 && !unit->reports_percentage) {
 					gpm_warning ("battery has a low capacity");
 					gpm_debug ("** EMIT: low-capacity");
 					g_signal_emit (cell, signals [LOW_CAPACITY], 0, unit->capacity);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]