hal: Branch 'hal-0_5_8-branch' - 3 commits
Sjoerd Simons
sjoerd at kemper.freedesktop.org
Wed Sep 27 12:14:36 PDT 2006
hald/linux/osspec.c | 85 +++++++++++++++++++++++++++++++++++++++++++++-------
hald/linux/pmu.c | 3 -
2 files changed, 74 insertions(+), 14 deletions(-)
New commits:
diff-tree e29998967c7d687581c780cb973b03bba3d41e62 (from 0b6ef0ec9a040906515ed097c0a939a35f8dcfc3)
Author: Sjoerd Simons <sjoerd at luon.net>
Date: Sun Sep 17 22:26:24 2006 +0200
create one common fallback for system.formfactor
Set system.formfactor fallback in exactly one place instead of three and be
carefull not to override if already set. Fixes bug on macintosh powerpc
machines where the detected value was overriden by the fallback.
(cherry picked from 80b89a74fe53fb036b5826fbea4ebec18d3378c8 commit)
diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index cb767f6..a2a1998 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -346,6 +346,10 @@ hotplug_queue_now_empty (void)
static void
computer_probing_helper_done (HalDevice *d)
{
+ /* if not set, set a default value */
+ if (!hal_device_has_property (d, "system.formfactor")) {
+ hal_device_property_set_string (d, "system.formfactor", "unknown");
+ }
di_search_and_merge (d, DEVICE_INFO_TYPE_INFORMATION);
di_search_and_merge (d, DEVICE_INFO_TYPE_POLICY);
@@ -363,9 +367,6 @@ computer_probing_pcbios_helper_done (Hal
const char *system_version;
if (exit_type == HALD_RUN_FAILED) {
- /* set a default value */
- if (!hal_device_has_property (d, "system.formfactor"))
- hal_device_property_set_string (d, "system.formfactor", "unknown");
goto out;
}
@@ -433,10 +434,7 @@ computer_probing_pcbios_helper_done (Hal
}
}
- } else {
- /* set a default value */
- hal_device_property_set_string (d, "system.formfactor", "unknown");
- }
+ }
}
out:
computer_probing_helper_done (d);
@@ -615,12 +613,10 @@ osspec_probe (void)
hald_runner_run (root, "hald-probe-smbios", NULL, HAL_HELPER_TIMEOUT,
computer_probing_pcbios_helper_done, NULL, NULL);
} else {
- /* set a default value, can be overridden by others */
- hal_device_property_set_string (root, "system.formfactor", "unknown");
/* no probing */
probe_openfirmware(root);
computer_probing_helper_done (root);
- }
+ }
}
DBusHandlerResult
diff-tree 0b6ef0ec9a040906515ed097c0a939a35f8dcfc3 (from 946edcebb99e8725e437d1915e0d5fb08093faa4)
Author: Sjoerd Simons <sjoerd at luon.net>
Date: Tue Sep 26 22:42:50 2006 +0200
Get some properties from openfirmware and use them to decide the formfactor
Read out model and compatible property out of openfirmware if possible. And use the openfirmware model property to decide what formfactor the system has.
(cherry picked from b83f4c83f60e8cf5da52a10e2546fef20053d25c commit)
diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index b9fb922..cb767f6 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -498,6 +498,68 @@ out:
hal_device_property_set_bool (d, "power_management.can_suspend_to_disk", can_hibernate);
}
+static void
+get_openfirmware_entry(HalDevice *d, char *property, char *entry,
+ gboolean multivalue) {
+ char *contents;
+ gsize length;
+ if (!g_file_get_contents(entry, &contents, &length, NULL)) {
+ return;
+ }
+ if (multivalue) {
+ gsize offset = 0;
+ while (offset < length) {
+ hal_device_property_strlist_append(d, property, contents + offset);
+ for (; offset < length - 1 && contents[offset] != '\0'; offset++)
+ ;
+ offset++;
+ }
+ } else {
+ hal_device_property_set_string(d, property, contents);
+ }
+ free(contents);
+}
+
+static void
+detect_openfirmware_formfactor(HalDevice *root) {
+ int x;
+ struct { gchar *model; gchar *formfactor; } model_formfactor[] =
+ {
+ { "RackMac" , "server" },
+ { "AAPL,3400" , "laptop" },
+ { "AAPL,3500" , "laptop" },
+ { "PowerBook" , "laptop" },
+ { "AAPL" , "desktop" },
+ { "iMac" , "desktop" },
+ { "PowerMac" , "desktop" },
+ {NULL, NULL }
+ };
+ const gchar *model =
+ hal_device_property_get_string(root, "openfirmware.model");
+
+ for (x = 0 ; model_formfactor[x].model ; x++) {
+ if (strstr(model, model_formfactor[x].model)) {
+ hal_device_property_set_string (root, "system.formfactor",
+ model_formfactor[x].formfactor);
+ break;
+ }
+ }
+}
+
+static void
+probe_openfirmware(HalDevice *root) {
+#define DEVICE_TREE "/proc/device-tree/"
+ if (!g_file_test(DEVICE_TREE, G_FILE_TEST_IS_DIR)) {
+ return;
+ }
+ get_openfirmware_entry(root, "openfirmware.model",
+ DEVICE_TREE "model", FALSE);
+ get_openfirmware_entry(root, "openfirmware.compatible",
+ DEVICE_TREE "compatible", TRUE);
+ detect_openfirmware_formfactor(root);
+}
+
+
void
osspec_probe (void)
{
@@ -549,7 +611,6 @@ osspec_probe (void)
*/
set_suspend_hibernate_keys (root);
- /* TODO: add prober for PowerMac's */
if (should_decode_dmi) {
hald_runner_run (root, "hald-probe-smbios", NULL, HAL_HELPER_TIMEOUT,
computer_probing_pcbios_helper_done, NULL, NULL);
@@ -557,6 +618,7 @@ osspec_probe (void)
/* set a default value, can be overridden by others */
hal_device_property_set_string (root, "system.formfactor", "unknown");
/* no probing */
+ probe_openfirmware(root);
computer_probing_helper_done (root);
}
}
diff --git a/hald/linux/pmu.c b/hald/linux/pmu.c
index d2ce912..b43d5f0 100644
--- a/hald/linux/pmu.c
+++ b/hald/linux/pmu.c
@@ -381,9 +381,6 @@ pmu_synthesize_hotplug_events (void)
/* Add Laptop Panel */
snprintf (path, sizeof (path), "%s/pmu/info", get_hal_proc_path ());
pmu_synthesize_item (path, PMU_TYPE_LAPTOP_PANEL);
-
- /* If the machine has got battery bays then this is a laptop. */
- hal_device_property_set_string (computer, "system.formfactor", "laptop");
}
/* setup timer for things that we need to poll */
diff-tree 946edcebb99e8725e437d1915e0d5fb08093faa4 (from d432770926e8cb95cc170ecd142ec2a319ed1d2f)
Author: Sjoerd Simons <sjoerd at luon.net>
Date: Sun Sep 17 20:25:25 2006 +0200
Set power_management.can_suspend to true for ppc systems using pmu
Always set power_management.can_suspend to true if the power_management.type is
pmu. Recent kernels don't report mem in /sys/power/state for ppc, but we have
our own utility that issues ioctl's to suspend.
(cherry picked from 0a14231944a194b6bc31b737ff9b0dbec91edebc commit)
diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index ed762a8..b9fb922 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -475,6 +475,11 @@ set_suspend_hibernate_keys (HalDevice *d
can_hibernate = TRUE;
free (poweroptions);
+ if (!strcmp(hal_device_property_get_string(d, "power_management.type"), "pmu")) {
+ /* We got our own helper for suspend PMU machines */
+ can_suspend = TRUE;
+ }
+
/* check for the presence of suspend2 */
if (access ("/proc/software_suspend", F_OK) == 0)
can_hibernate = TRUE;
More information about the hal-commit
mailing list