hal: Branch 'master'

Danny Kukawka dkukawka at kemper.freedesktop.org
Thu Aug 23 13:02:10 PDT 2007


 hald/linux/acpi.c   |   36 ++++++++++++++++++++++++++----------
 hald/linux/acpi.h   |    2 ++
 hald/linux/osspec.c |    7 +++++++
 3 files changed, 35 insertions(+), 10 deletions(-)

New commits:
diff-tree cd0d218accc1e1f665069028566c4d949c19f73c (from c940b3cb8e6951e4e8d94fc5661dfc8982860bfa)
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Thu Aug 23 22:02:02 2007 +0200

    fix detection of system.formfactor=laptop for ACPI machines
    
    There are problems on laptops if the smbios.chassis.type is not directly
    mapped from the smbios to 'laptop' (e.g. smbios tell it's 'Unknown').
    
    In this case HAL currently call as next coldplug_synthesize_events() after
    the smbios probing and first then start to synthesizing the ACPI events/
    devices. But in the ACPI code HAL set system.formfactor=laptop, if it isn't
    already detected as Laptop (e.g. if the machine has a battery).
    
    The problem is: all other devices as e.g. the WLAN device get synthesized
    before the ACPI devices. Hence all fdi-file checks for laptop can fail with
    the result:
     * the properties get not set as planed
     * e.g. the IPW killswitch device get not spawned
    
    Fixed the problem for the ACPI case by check for a battery bay or a lid
    button in /proc/acpi/*. we can ignore the APM case for the moment. Changed
    acpi_synthesize() a little bit to let the function run without synthesize
    ACPI devices because this function already check if the machine is a laptop.
    
    In computer_probing_helper_done() HAL check now if system.formfactor isn't
    set or not 'laptop' and calls acpi_check_is_laptop() in this case, to do the
    needed checks and set if needed the machine as latop as soon as possible
    before othere devices get handeled.

diff --git a/hald/linux/acpi.c b/hald/linux/acpi.c
index 2aa14a4..cc97f15 100644
--- a/hald/linux/acpi.c
+++ b/hald/linux/acpi.c
@@ -739,13 +739,14 @@ acpi_synthesize_item (const gchar *fullp
  *  acpi_synthesize:
  *  @path:		The ACPI path, e.g. "/proc/acpi/battery"
  *  @acpi_type:		The type of device, e.g. ACPI_TYPE_BATTERY
+ *  @synthesize:	If a device should get synthesized
  *
  *  Synthesizes generic acpi objects, i.e. registers all the objects of type
  *  into HAL. This lets us have more than one type of device e.g. BATx
  *  in the same battery class. 
  */
 static void
-acpi_synthesize (const gchar *path, int acpi_type)
+acpi_synthesize (const gchar *path, int acpi_type, gboolean synthesize)
 {
 	const gchar *f;
 	gboolean is_laptop = FALSE;
@@ -786,8 +787,10 @@ acpi_synthesize (const gchar *path, int 
 			}
 		}
 
-		snprintf (buf, sizeof (buf), "%s/%s", path, f);
-		acpi_synthesize_item (buf, acpi_type);
+		if (synthesize) {
+			snprintf (buf, sizeof (buf), "%s/%s", path, f);
+			acpi_synthesize_item (buf, acpi_type);
+		}
 	}
 
 	/* close directory */
@@ -899,18 +902,18 @@ acpi_synthesize_hotplug_events (void)
 	}
 
 	/* collect batteries */
-	acpi_synthesize ("/proc/acpi/battery", ACPI_TYPE_BATTERY);
+	acpi_synthesize ("/proc/acpi/battery", ACPI_TYPE_BATTERY, TRUE);
 	/* collect processors */
-	acpi_synthesize ("/proc/acpi/processor", ACPI_TYPE_PROCESSOR);
+	acpi_synthesize ("/proc/acpi/processor", ACPI_TYPE_PROCESSOR, TRUE);
 	/* collect fans */
-	acpi_synthesize ("/proc/acpi/fan", ACPI_TYPE_FAN);
+	acpi_synthesize ("/proc/acpi/fan", ACPI_TYPE_FAN, TRUE);
 	/* collect AC adapters */
-	acpi_synthesize ("/proc/acpi/ac_adapter", ACPI_TYPE_AC_ADAPTER);
+	acpi_synthesize ("/proc/acpi/ac_adapter", ACPI_TYPE_AC_ADAPTER, TRUE);
 
 	/* collect buttons */
-	acpi_synthesize ("/proc/acpi/button/lid", ACPI_TYPE_BUTTON);
-	acpi_synthesize ("/proc/acpi/button/power", ACPI_TYPE_BUTTON);
-	acpi_synthesize ("/proc/acpi/button/sleep", ACPI_TYPE_BUTTON);
+	acpi_synthesize ("/proc/acpi/button/lid", ACPI_TYPE_BUTTON, TRUE);
+	acpi_synthesize ("/proc/acpi/button/power", ACPI_TYPE_BUTTON, TRUE);
+	acpi_synthesize ("/proc/acpi/button/sleep", ACPI_TYPE_BUTTON, TRUE);
 
 	/*
 	 * Collect video adaptors (from vendor added modules)
@@ -1275,3 +1278,16 @@ acpi_generate_remove_hotplug_event (HalD
 	hotplug_event->acpi.acpi_type = acpi_type;
 	return hotplug_event;
 }
+
+void 
+acpi_check_is_laptop (const gchar *acpi_type) 
+{
+	if (acpi_type != NULL) {
+
+		if (strcmp (acpi_type, "BATTERY") == 0) {
+			acpi_synthesize ("/proc/acpi/battery", ACPI_TYPE_BATTERY, FALSE);
+		} else if (strcmp (acpi_type, "LID") == 0) {
+			acpi_synthesize ("/proc/acpi/button/lid", ACPI_TYPE_BUTTON, FALSE);
+		} 
+	}
+}
diff --git a/hald/linux/acpi.h b/hald/linux/acpi.h
index be02c70..00d2a2a 100644
--- a/hald/linux/acpi.h
+++ b/hald/linux/acpi.h
@@ -33,6 +33,7 @@ void hotplug_event_begin_remove_acpi (co
 gboolean acpi_rescan_device (HalDevice *d);
 HotplugEvent *acpi_generate_add_hotplug_event (HalDevice *d);
 HotplugEvent *acpi_generate_remove_hotplug_event (HalDevice *d);
+void acpi_check_is_laptop (const gchar *acpi_type);
 #else /* HAVE_ACPI */
 static inline gboolean acpi_synthesize_hotplug_events (void) {return FALSE;}
 static inline void hotplug_event_begin_add_acpi (const gchar *acpi_path, int acpi_type, HalDevice *parent, void *end_token) {return;}
@@ -40,6 +41,7 @@ static inline void hotplug_event_begin_r
 static inline gboolean acpi_rescan_device (HalDevice *d) {return FALSE;}
 static inline HotplugEvent *acpi_generate_add_hotplug_event (HalDevice *d) {return NULL;}
 static inline HotplugEvent *acpi_generate_remove_hotplug_event (HalDevice *d) {return NULL;}
+static inline void acpi_check_is_laptop (const gchar *acpi_type) {return;}
 #endif /* HAVE_ACPI */
 
 #endif /* ACPI_H */
diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index 3512c6a..39ba0c0 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -393,6 +393,13 @@ hotplug_queue_now_empty (void)
 static void
 computer_probing_helper_done (HalDevice *d)
 {
+	/* check if this is may a laptop */
+	if (!hal_device_has_property (d, "system.formfactor") || 
+	    (strcmp (hal_device_property_get_string (d, "system.formfactor"), "laptop") != 0)) {
+		HAL_INFO (("Check if the machine is may a laptop ..."));
+		acpi_check_is_laptop("BATTERY");
+		acpi_check_is_laptop("LID");
+	}
 	/* if not set, set a default value */
 	if (!hal_device_has_property (d, "system.formfactor")) {
 		hal_device_property_set_string (d, "system.formfactor", "unknown");


More information about the hal-commit mailing list