hal/hald/linux2 acpi.c,1.10,1.11

David Zeuthen david at freedesktop.org
Wed Mar 2 12:50:25 PST 2005


Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv29447/hald/linux2

Modified Files:
	acpi.c 
Log Message:
2005-03-02  David Zeuthen  <davidz at redhat.com>

	* hald/linux2/acpi.c (processor_refresh): s/system.processor/processor/

2005-03-02  Richard Hughes  <richard at hughsie.com>

	* hald/linux2/acpi.c (processor_refresh, fan_refresh): New
	functions to handle additional ACPI devices.

	* hald/linux2/acpi.c (acpi_synthesize_hotplug_events): Added
	processor and fan handlers.
 


Index: acpi.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/acpi.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- acpi.c	2 Mar 2005 19:22:10 -0000	1.10
+++ acpi.c	2 Mar 2005 20:50:23 -0000	1.11
@@ -38,6 +38,8 @@
 
 enum {
 	ACPI_TYPE_BATTERY,
+	ACPI_TYPE_PROCESSOR,
+	ACPI_TYPE_FAN,
 	ACPI_TYPE_AC_ADAPTER,
 	ACPI_TYPE_BUTTON
 };
@@ -108,6 +110,44 @@
 }
 
 static gboolean
+processor_refresh (HalDevice *d, ACPIDevHandler *handler)
+{
+	const char *path;
+
+	path = hal_device_property_get_string (d, "linux.acpi_path");
+	if (path == NULL)
+		return FALSE;
+
+	hal_device_property_set_string (d, "info.product", "Processor");
+	hal_device_property_set_string (d, "info.category", "processor");
+	hal_device_add_capability (d, "processor");
+	hal_util_set_int_elem_from_file (d, "processor.number", path, 
+					 "info", "processor id", 0, 10);
+	hal_util_set_bool_elem_from_file (d, "processor.can_throttle", path, 
+					  "info", "throttling control", 0, "yes");
+	return TRUE;
+}
+
+static gboolean
+fan_refresh (HalDevice *d, ACPIDevHandler *handler)
+{
+	const char *path;
+
+	path = hal_device_property_get_string (d, "linux.acpi_path");
+	if (path == NULL)
+		return FALSE;
+
+	hal_device_property_set_string (d, "info.product", "Fan");
+	hal_device_property_set_string (d, "info.category", "fan");
+	hal_device_add_capability (d, "fan");
+	hal_util_set_int_elem_from_file (d, "processor.number", path, 
+					 "info", "processor id", 0, 10);
+	hal_util_set_bool_elem_from_file (d, "fan.enabled", path, 
+					  "state", "status", 0, "on");
+	return TRUE;
+}
+
+static gboolean
 ac_adapter_refresh (HalDevice *d, ACPIDevHandler *handler)
 {
 	const char *path;
@@ -234,6 +274,14 @@
 	snprintf (path, sizeof (path), "%s/acpi/battery", get_hal_proc_path ());
 	acpi_synthesize (path, ACPI_TYPE_BATTERY);
 
+	/* collect processors */
+	snprintf (path, sizeof (path), "%s/acpi/processor", get_hal_proc_path ());
+	acpi_synthesize (path, ACPI_TYPE_PROCESSOR);
+
+	/* collect fans */
+	snprintf (path, sizeof (path), "%s/acpi/fan", get_hal_proc_path ());
+	acpi_synthesize (path, ACPI_TYPE_FAN);
+
 	/* collect AC adapters */
 	snprintf (path, sizeof (path), "%s/acpi/ac_adapter", get_hal_proc_path ());
 	acpi_synthesize (path, ACPI_TYPE_AC_ADAPTER);
@@ -295,6 +343,22 @@
 	.remove      = acpi_generic_remove
 };
 
+static ACPIDevHandler acpidev_handler_processor = { 
+	.acpi_type   = ACPI_TYPE_PROCESSOR,
+	.add         = acpi_generic_add,
+	.compute_udi = acpi_generic_compute_udi,
+	.refresh     = processor_refresh,
+	.remove      = acpi_generic_remove
+};
+
+static ACPIDevHandler acpidev_handler_fan = { 
+	.acpi_type   = ACPI_TYPE_FAN,
+	.add         = acpi_generic_add,
+	.compute_udi = acpi_generic_compute_udi,
+	.refresh     = fan_refresh,
+	.remove      = acpi_generic_remove
+};
+
 static ACPIDevHandler acpidev_handler_button = { 
 	.acpi_type   = ACPI_TYPE_BUTTON,
 	.add         = acpi_generic_add,
@@ -313,6 +377,8 @@
 
 static ACPIDevHandler *acpi_handlers[] = {
 	&acpidev_handler_battery,
+	&acpidev_handler_processor,
+	&acpidev_handler_fan,
 	&acpidev_handler_button,
 	&acpidev_handler_ac_adapter,
 	NULL




More information about the hal-commit mailing list