diff options
author | jmcneill <jmcneill> | 2008-11-27 14:17:10 +0000 |
---|---|---|
committer | jmcneill <jmcneill> | 2008-11-27 14:17:10 +0000 |
commit | bef4e1e45cbb5e00df0edc78215761aa58c4e97d (patch) | |
tree | f4cf88fb9262f12206a48853e962cd27d25a4220 /sysutils/hal/files | |
parent | e2c8c9c270cd606f8fc80db56fcfacbc66f8733c (diff) | |
download | pkgsrc-bef4e1e45cbb5e00df0edc78215761aa58c4e97d.tar.gz |
hald-netbsd: mark the system type as 'laptop' if acpibat0 is found, and
don't continually send notifications while charging and discharging.
Bump PKGREVISION.
Diffstat (limited to 'sysutils/hal/files')
-rw-r--r-- | sysutils/hal/files/hald-netbsd/devinfo_misc.c | 12 | ||||
-rw-r--r-- | sysutils/hal/files/hald-netbsd/drvctl.c | 36 | ||||
-rw-r--r-- | sysutils/hal/files/hald-netbsd/drvctl.h | 1 | ||||
-rw-r--r-- | sysutils/hal/files/hald-netbsd/envsys.c | 32 |
4 files changed, 67 insertions, 14 deletions
diff --git a/sysutils/hal/files/hald-netbsd/devinfo_misc.c b/sysutils/hal/files/hald-netbsd/devinfo_misc.c index e7c766b4fee..700c642c04b 100644 --- a/sysutils/hal/files/hald-netbsd/devinfo_misc.c +++ b/sysutils/hal/files/hald-netbsd/devinfo_misc.c @@ -27,6 +27,7 @@ #include "../device_info.h" #include "../util.h" #include "devinfo_misc.h" +#include "drvctl.h" static HalDevice *devinfo_computer_add(HalDevice *, const char *, char *, char *); static HalDevice *devinfo_cpu_add(HalDevice *, const char *, char *,char *); @@ -97,6 +98,11 @@ devinfo_computer_add(HalDevice *parent, const char *devnode, char *devfs_path, c hal_device_property_set_bool (d, "power_management.can_hibernate", FALSE); } + if (drvctl_find_device ("acpibat0", NULL) == TRUE) + hal_device_property_set_string (d, "system.formfactor", "laptop"); + else + hal_device_property_set_string (d, "system.formfactor", "desktop"); /* XXX */ + devinfo_add_enqueue (d, devnode, &devinfo_default_handler); return d; @@ -127,7 +133,6 @@ devinfo_cpu_add(HalDevice *parent, const char *devnode, char *devfs_path, char * static void devinfo_default_apply_quirks(HalDevice *d, const char *devnode) { - HalDevice *computer = hal_device_store_match_key_value_string (hald_get_gdl (), "info.udi", "/org/freedesktop/Hal/devices/computer"); /* acpiacad(4) */ if (strncmp (devnode, "acpiacad", 8) == 0) { @@ -139,11 +144,6 @@ devinfo_default_apply_quirks(HalDevice *d, const char *devnode) HAL_INFO (("%s: applying acpibat quirks")); hal_device_add_capability (d, "battery"); hal_device_property_set_string (d, "battery.type", "primary"); - - if (computer) { - HAL_INFO (("%s: applying acpibat computer quirks")); - hal_device_property_set_string (computer, "system.formfactor", "laptop"); - } } } diff --git a/sysutils/hal/files/hald-netbsd/drvctl.c b/sysutils/hal/files/hald-netbsd/drvctl.c index a1b697bbc50..32e816233aa 100644 --- a/sysutils/hal/files/hald-netbsd/drvctl.c +++ b/sysutils/hal/files/hald-netbsd/drvctl.c @@ -99,7 +99,6 @@ drvctl_iochannel_data (GIOChannel *source, HAL_INFO (("DRVGETEVENT event=%s device=%s", event, device)); - if (strcmp (event, "device-attach") == 0) { drvctl_dev_add (device); } else { @@ -182,6 +181,41 @@ drvctl_list(const gchar *name, struct devlistargs *laa) HAL_WARNING (("DRVLISTDEV/3 expected %d children, got %d", children, laa->l_childname)); } +gboolean +drvctl_find_device(const gchar *devnode, prop_dictionary_t *properties) +{ + prop_dictionary_t command_dict; + prop_dictionary_t args_dict; + prop_dictionary_t results_dict; + int err; + + command_dict = prop_dictionary_create (); + args_dict = prop_dictionary_create (); + + prop_dictionary_set_cstring_nocopy (command_dict, "drvctl-command", "get-properties"); + prop_dictionary_set_cstring_nocopy (args_dict, "device-name", devnode); + prop_dictionary_set (command_dict, "drvctl-arguments", args_dict); + prop_object_release (args_dict); + + err = prop_dictionary_sendrecv_ioctl (command_dict, drvctl_fd, + DRVCTLCOMMAND, &results_dict); + prop_object_release (command_dict); + if (err) + return FALSE; + + if (prop_dictionary_get_int8 (results_dict, "drvctl-error", &err) == false || err != 0) { + prop_object_release (results_dict); + return FALSE; + } + + if (properties) + *properties = prop_dictionary_get (results_dict, "drvctl-result-data"); + + prop_object_release (results_dict); + + return TRUE; +} + static gboolean drvctl_find_device_with_child(const gchar *curnode, const gchar *devnode, char *parent) diff --git a/sysutils/hal/files/hald-netbsd/drvctl.h b/sysutils/hal/files/hald-netbsd/drvctl.h index b70e7200d79..9e94fae49bd 100644 --- a/sysutils/hal/files/hald-netbsd/drvctl.h +++ b/sysutils/hal/files/hald-netbsd/drvctl.h @@ -19,5 +19,6 @@ gboolean drvctl_init(void); void drvctl_fini(void); int drvctl_list(const gchar *devnode, struct devlistargs *laa); gboolean drvctl_find_parent(const gchar *devnode, char *parent); +gboolean drvctl_find_device(const gchar *devnode, prop_dictionary_t *properties); #endif /* DRVCTL_H */ diff --git a/sysutils/hal/files/hald-netbsd/envsys.c b/sysutils/hal/files/hald-netbsd/envsys.c index d5491224060..3440bf9b975 100644 --- a/sysutils/hal/files/hald-netbsd/envsys.c +++ b/sysutils/hal/files/hald-netbsd/envsys.c @@ -1,4 +1,4 @@ -/* $NetBSD: envsys.c,v 1.2 2008/11/27 12:24:02 jmcneill Exp $ */ +/* $NetBSD: envsys.c,v 1.3 2008/11/27 14:17:11 jmcneill Exp $ */ /*- * Copyright (c) 2008 Jared D. McNeill <jmcneill@invisible.ca> @@ -62,6 +62,12 @@ static void envsys_handle_devnode(const char *devnode, prop_array_t properties); static void envsys_acadapter_handler(HalDevice *d, prop_array_t properties); static void envsys_battery_handler(HalDevice *d, prop_array_t properties); +enum battery_state { + CHARGING, + DISCHARGING, + NORMAL +}; + static struct envsys_devmap { const char *capability; void (*handler)(HalDevice *d, prop_array_t properties); @@ -170,12 +176,11 @@ envsys_battery_handler(HalDevice *d, prop_array_t properties) { prop_object_iterator_t iter; prop_dictionary_t prop; + enum battery_state battstate = NORMAL; device_property_atomic_update_begin (); hal_device_property_set_bool (d, "battery.is_rechargeable", TRUE); - hal_device_property_set_bool (d, "battery.rechargeable.is_charging", FALSE); - hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", FALSE); iter = prop_array_iterator (properties); while ((prop = (prop_dictionary_t)prop_object_iterator_next (iter)) != NULL) { @@ -206,16 +211,29 @@ envsys_battery_handler(HalDevice *d, prop_array_t properties) hal_device_property_set_int (d, "battery.charge_level.percentage", 0); } else if (strcmp (descr, "charge rate") == 0) { - hal_device_property_set_bool (d, "battery.rechargeable.is_charging", TRUE); - hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", FALSE); + battstate = CHARGING; hal_device_property_set_int (d, "battery.charge_level.rate", intval / 3600); } else if (strcmp (descr, "discharge rate") == 0) { - hal_device_property_set_bool (d, "battery.rechargeable.is_charging", FALSE); - hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", TRUE); + battstate = DISCHARGING; hal_device_property_set_int (d, "battery.charge_level.rate", intval / 3600); } } + switch (battstate) { + case NORMAL: + hal_device_property_set_bool (d, "battery.rechargeable.is_charging", FALSE); + hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", FALSE); + break; + case CHARGING: + hal_device_property_set_bool (d, "battery.rechargeable.is_charging", TRUE); + hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", FALSE); + break; + case DISCHARGING: + hal_device_property_set_bool (d, "battery.rechargeable.is_charging", FALSE); + hal_device_property_set_bool (d, "battery.rechargeable.is_discharging", TRUE); + break; + } + device_property_atomic_update_end (); prop_object_iterator_release (iter); |