hal/hald/linux2 acpi.c, 1.39, 1.40 apm.c, 1.12, 1.13 osspec.c, 1.29,
1.30
Danny Kukawka
dkukawka at freedesktop.org
Tue Oct 25 09:06:15 PDT 2005
Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv17626/hald/linux2
Modified Files:
acpi.c apm.c osspec.c
Log Message:
2005-10-25 Danny Kukawka <danny.kukawka at web.de>
* hald/linux2/acpi.c: (acpi_synthesize): Check if there is a battery
bay and/or a LID button to verify if the machine is a latop. If so
change the key system.formfactor to 'laptop' (to workaround missing/
unknown information from smbios).
Fixed typo in code documentation.
* hald/linux2/apm.c: (battery_refresh),
(apm_synthesize_hotplug_events), (apm_generic_compute_udi): Fixed keys
if the battery is removed. Changed check for battery and added more
criterions to be sure that we add only known values. Also fixed the
udi of APM devices, now the udi contains the name of the devicetype.
* hald/linux2/osspec.c: (computer_probing_pcbios_helper_done):
Fixed creation of key system.formfactor from smbios information to be
sure never overwrite already set key (e.g. from APM/ACPI/PMU).
Index: acpi.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/acpi.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- acpi.c 15 Oct 2005 15:15:45 -0000 1.39
+++ acpi.c 25 Oct 2005 16:06:13 -0000 1.40
@@ -253,7 +253,7 @@
}
-/** Fallback polling method to refresh battery bojects is plugged in
+/** Fallback polling method to refresh battery objects is plugged in
*
* @return TRUE
*
@@ -755,6 +755,8 @@
acpi_synthesize (const gchar *path, int acpi_type)
{
const gchar *f;
+ gchar _path[HAL_PATH_MAX];
+ gboolean is_laptop = FALSE;
GDir *dir;
GError *error = NULL;
@@ -768,6 +770,29 @@
/* do for each object in directory */
while ((f = g_dir_read_name (dir)) != NULL) {
gchar buf[HAL_PATH_MAX];
+
+ /* check if there is a battery bay or a LID button */
+ if (!is_laptop) {
+ if ( acpi_type == ACPI_TYPE_BATTERY ) {
+ is_laptop = TRUE;
+ } else if ( acpi_type == ACPI_TYPE_BUTTON ) {
+ snprintf (_path, sizeof (_path), "%s/acpi/button/lid", get_hal_proc_path ());
+ if ( strcmp (path, _path) == 0 )
+ is_laptop = TRUE;
+ }
+ }
+ /* if there is a battery bay or LID, this is a laptop -> set the formfactor */
+ if ( is_laptop ) {
+ HalDevice *computer;
+
+ if ((computer = hal_device_store_find (hald_get_gdl (), "/org/freedesktop/Hal/devices/computer")) == NULL &&
+ (computer = hal_device_store_find (hald_get_tdl (), "/org/freedesktop/Hal/devices/computer")) == NULL) {
+ HAL_ERROR (("No computer object?"));
+ } else {
+ hal_device_property_set_string (computer, "system.formfactor", "laptop");
+ }
+ }
+
snprintf (buf, sizeof (buf), "%s/%s", path, f);
acpi_synthesize_item (buf, acpi_type);
}
Index: apm.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/apm.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- apm.c 19 Aug 2005 19:32:20 -0000 1.12
+++ apm.c 25 Oct 2005 16:06:13 -0000 1.13
@@ -129,6 +129,7 @@
int remaining_time;
gboolean is_charging;
gboolean is_discharging;
+ HalDevice *computer;
APMInfo i;
path = hal_device_property_get_string (d, "linux.apm_path");
@@ -144,18 +145,38 @@
read_from_apm (path, &i);
- if (i.battery_percentage <= 0) {
+ /* we check this to know if there is a battery:
+ * - if i.battery_percentage < 0: no battery
+ * - if driver version starts with [B]: old style (pre-0.7), not supported -> no battery
+ * - if battery status == 0xff : no battery present
+ */
+ if (i.battery_percentage < 0 || i.driver_version[0] == 'B' || i.battery_status == 0xff ) {
device_property_atomic_update_begin ();
hal_device_property_remove (d, "battery.is_rechargeable");
hal_device_property_remove (d, "battery.rechargeable.is_charging");
hal_device_property_remove (d, "battery.rechargeable.is_discharging");
hal_device_property_remove (d, "battery.charge_level.unit");
hal_device_property_remove (d, "battery.charge_level.current");
+ /* Is this key really needed? We don't know the value of this key */
hal_device_property_remove (d, "battery.charge_level.last_full");
hal_device_property_remove (d, "battery.charge_level.design");
+ hal_device_property_remove (d, "battery.charge_level.percentage");
+ hal_device_property_remove (d, "battery.remaining_time");
hal_device_property_set_bool (d, "battery.present", FALSE);
device_property_atomic_update_end ();
} else {
+ if ((computer = hal_device_store_find (hald_get_gdl (), "/org/freedesktop/Hal/devices/computer")) == NULL &&
+ (computer = hal_device_store_find (hald_get_tdl (), "/org/freedesktop/Hal/devices/computer")) == NULL) {
+ HAL_ERROR (("No computer object?"));
+ } else {
+ if (!hal_device_has_property(computer, "system.formfactor")) {
+ hal_device_property_set_string (computer, "system.formfactor", "laptop");
+ }
+ else if (strcmp (hal_device_property_get_string (computer, "system.formfactor"), "laptop") != 0) {
+ hal_device_property_set_string (computer, "system.formfactor", "laptop");
+ }
+ }
+
device_property_atomic_update_begin ();
hal_device_property_set_bool (d, "battery.is_rechargeable", TRUE);
hal_device_property_set_bool (d, "battery.present", TRUE);
@@ -163,7 +184,8 @@
hal_device_property_set_string (d, "battery.charge_level.unit", "percent");
hal_device_property_set_int (d, "battery.charge_level.design", 100);
- hal_device_property_set_int (d, "battery.charge_level.last_full", 100);
+ /* Is this key really needed? We don't know the value of this key */
+ hal_device_property_set_int (d, "battery.charge_level.last_full", 100);
/* TODO: clean the logic below up; it appears my T41
* with 2.6.10-1.1110_FC4 and acpi=off always report
@@ -305,9 +327,20 @@
apm_generic_compute_udi (HalDevice *d, APMDevHandler *handler)
{
gchar udi[256];
- hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
- "/org/freedesktop/Hal/devices/apm_%d",
- hal_device_property_get_int (d, "linux.apm_type"));
+
+ if (handler->apm_type == APM_TYPE_BATTERY ) {
+ hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+ "/org/freedesktop/Hal/devices/apm_battery");
+
+ } else if (handler->apm_type == APM_TYPE_AC_ADAPTER ) {
+ hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+ "/org/freedesktop/Hal/devices/apm_ac_adapter");
+ } else {
+ hal_util_compute_udi (hald_get_gdl (), udi, sizeof (udi),
+ "/org/freedesktop/Hal/devices/apm_%d",
+ hal_device_property_get_int (d, "info.category"));
+ }
+
hal_device_set_udi (d, udi);
hal_device_property_set_string (d, "info.udi", udi);
return TRUE;
Index: osspec.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/osspec.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- osspec.c 27 Sep 2005 09:42:12 -0000 1.29
+++ osspec.c 25 Oct 2005 16:06:13 -0000 1.30
@@ -478,7 +478,9 @@
for (i = 0; chassis_map[i] != NULL; i += 2) {
if (strcmp (chassis_map[i], chassis_type) == 0) {
- hal_device_property_set_string (d, "system.formfactor", chassis_map[i+1]);
+ /* check if the key is already set to prevent overwrite keys */
+ if (!hal_device_has_property(d, "system.formfactor"))
+ hal_device_property_set_string (d, "system.formfactor", chassis_map[i+1]);
break;
}
}
More information about the hal-commit
mailing list