summaryrefslogtreecommitdiffstats
path: root/x11/gnome-applets/files/patch-battstat_power-management.c
diff options
context:
space:
mode:
authormarcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059>2005-07-04 05:35:31 +0800
committermarcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059>2005-07-04 05:35:31 +0800
commit34bcee1b7fbce3aedae06dd504c838965a8c5e28 (patch)
tree819711a41ee772ea689f66de6163282757dbed98 /x11/gnome-applets/files/patch-battstat_power-management.c
parent9cb041f482556c75f90abd698ae70997c3924b4a (diff)
downloadmarcuscom-ports-34bcee1b7fbce3aedae06dd504c838965a8c5e28.tar
marcuscom-ports-34bcee1b7fbce3aedae06dd504c838965a8c5e28.tar.gz
marcuscom-ports-34bcee1b7fbce3aedae06dd504c838965a8c5e28.tar.bz2
marcuscom-ports-34bcee1b7fbce3aedae06dd504c838965a8c5e28.tar.lz
marcuscom-ports-34bcee1b7fbce3aedae06dd504c838965a8c5e28.tar.xz
marcuscom-ports-34bcee1b7fbce3aedae06dd504c838965a8c5e28.tar.zst
marcuscom-ports-34bcee1b7fbce3aedae06dd504c838965a8c5e28.zip
Update to 2.11.1, and port cpufreq and the latest battstat code.
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@4157 df743ca5-7f9a-e211-a948-0013205c9059
Diffstat (limited to 'x11/gnome-applets/files/patch-battstat_power-management.c')
-rw-r--r--x11/gnome-applets/files/patch-battstat_power-management.c112
1 files changed, 112 insertions, 0 deletions
diff --git a/x11/gnome-applets/files/patch-battstat_power-management.c b/x11/gnome-applets/files/patch-battstat_power-management.c
new file mode 100644
index 000000000..ab70e5be4
--- /dev/null
+++ b/x11/gnome-applets/files/patch-battstat_power-management.c
@@ -0,0 +1,112 @@
+--- battstat/power-management.c.orig Sun Jul 3 16:55:38 2005
++++ battstat/power-management.c Sun Jul 3 17:02:43 2005
+@@ -191,16 +191,40 @@ apm_readinfo (BatteryStatus *status)
+
+ #elif __FreeBSD__
+
++#if defined(__i386__)
+ #include <machine/apm_bios.h>
++#endif
+ #include "acpi-freebsd.h"
+
+ static struct acpi_info acpiinfo;
+ static gboolean using_acpi;
+ static int acpi_count;
++static int acpiwatch;
+ static struct apm_info apminfo;
+
++gboolean acpi_freebsd_read(struct apm_info *apminfo, struct acpi_info *acpiinfo);
++
+ #define APMDEVICE "/dev/apm"
+
++static gboolean acpi_callback (GIOChannel * chan, GIOCondition cond, gpointer data)
++{
++ gboolean read_error;
++ if (cond & (G_IO_ERR | G_IO_HUP)) {
++ acpi_freebsd_cleanup(&acpiinfo);
++ return FALSE;
++ }
++
++ if (acpi_process_event(&acpiinfo, &read_error)) {
++ acpi_freebsd_read(&apminfo, &acpiinfo);
++ }
++ else if (read_error) {
++ acpi_freebsd_cleanup(&acpiinfo);
++ return FALSE;
++ }
++
++ return TRUE;
++}
++
+ static const char *
+ apm_readinfo (BatteryStatus *status)
+ {
+@@ -208,21 +232,27 @@ apm_readinfo (BatteryStatus *status)
+
+ if (DEBUG) g_print("apm_readinfo() (FreeBSD)\n");
+
+- if (using_acpi) {
++ if (using_acpi && (!acpiinfo.event_inited || acpiinfo.event_fd >= 0)) {
+ if (acpi_count <= 0) {
+ acpi_count = 30;
+- acpi_process_event(&acpiinfo);
++ if (!acpiinfo.event_inited) {
++ acpi_freebsd_update(&acpiinfo);
++ }
+ if (acpi_freebsd_read(&apminfo, &acpiinfo) == FALSE)
+ return ERR_FREEBSD_ACPI;
+ }
+ acpi_count--;
+ }
+- else
+- {
+- /* This is how I read the information from the APM subsystem under
+- FreeBSD. Each time this functions is called (once every second)
+- the APM device is opened, read from and then closed.
+- */
++ else if (using_acpi && acpiinfo.event_inited) {
++ if (acpi_freebsd_init(&acpiinfo)) {
++ acpiwatch = g_io_add_watch (acpiinfo.channel,
++ G_IO_IN | G_IO_ERR | G_IO_HUP,
++ acpi_callback, NULL);
++ acpi_freebsd_read(&apminfo, &acpiinfo);
++ }
++ }
++ else {
++#if defined(__i386__)
+ fd = open(APMDEVICE, O_RDONLY);
+ if (fd == -1) {
+ return ERR_OPEN_APMDEV;
+@@ -236,6 +266,9 @@ apm_readinfo (BatteryStatus *status)
+ if(apminfo.ai_status == 0)
+ return ERR_APM_E;
+ }
++#else
++ return ERR_OPEN_APMDEV;
++#endif
+
+ status->present = TRUE;
+ status->on_ac_power = apminfo.ai_acline ? 1 : 0;
+@@ -480,6 +513,12 @@ power_management_initialise( void )
+ }
+ else
+ using_acpi = FALSE;
++
++ if (using_acpi && acpiinfo.event_fd >= 0) {
++ acpiwatch = g_io_add_watch (acpiinfo.channel,
++ G_IO_IN | G_IO_ERR | G_IO_HUP,
++ acpi_callback, NULL);
++ }
+ #endif
+ pm_initialised = 1;
+
+@@ -504,6 +543,9 @@ power_management_cleanup( void )
+ }
+ #elif defined(__FreeBSD__)
+ if (using_acpi) {
++ if (acpiwatch != 0)
++ g_source_remove(acpiwatch);
++ acpiwatch = 0;
+ acpi_freebsd_cleanup(&acpiinfo);
+ }
+ #endif