diff options
author | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2005-02-28 16:02:03 +0800 |
---|---|---|
committer | marcus <marcus@df743ca5-7f9a-e211-a948-0013205c9059> | 2005-02-28 16:02:03 +0800 |
commit | 427a7c66c717dc61e528f14a57c3368b11ef98fd (patch) | |
tree | 9e68af6eff159ad04d5065ab1a00a7cc06ef75a1 /x11/gnome-applets/files | |
parent | 1017b9301609ff13b496626d1f2708aa20968d93 (diff) | |
download | marcuscom-ports-427a7c66c717dc61e528f14a57c3368b11ef98fd.tar marcuscom-ports-427a7c66c717dc61e528f14a57c3368b11ef98fd.tar.gz marcuscom-ports-427a7c66c717dc61e528f14a57c3368b11ef98fd.tar.bz2 marcuscom-ports-427a7c66c717dc61e528f14a57c3368b11ef98fd.tar.lz marcuscom-ports-427a7c66c717dc61e528f14a57c3368b11ef98fd.tar.xz marcuscom-ports-427a7c66c717dc61e528f14a57c3368b11ef98fd.tar.zst marcuscom-ports-427a7c66c717dc61e528f14a57c3368b11ef98fd.zip |
We do not need dev/contrib/acpica/acpi.h to build battstat. This will let
us build without kernel source on -CURRENT.
git-svn-id: svn://creme-brulee.marcuscom.com/ports/trunk@3728 df743ca5-7f9a-e211-a948-0013205c9059
Diffstat (limited to 'x11/gnome-applets/files')
-rw-r--r-- | x11/gnome-applets/files/patch-battstat-acpi | 215 |
1 files changed, 107 insertions, 108 deletions
diff --git a/x11/gnome-applets/files/patch-battstat-acpi b/x11/gnome-applets/files/patch-battstat-acpi index 5d7ac15bd..9d4a21e13 100644 --- a/x11/gnome-applets/files/patch-battstat-acpi +++ b/x11/gnome-applets/files/patch-battstat-acpi @@ -105,9 +105,112 @@ NULL }; ---- battstat/acpi-freebsd.c.orig Wed Feb 16 02:48:57 2005 -+++ battstat/acpi-freebsd.c Wed Feb 16 02:53:37 2005 -@@ -0,0 +1,207 @@ +--- battstat/power-management.c.orig Thu Jan 13 23:06:40 2005 ++++ battstat/power-management.c Wed Feb 16 02:58:10 2005 +@@ -76,6 +76,14 @@ + #ifdef __FreeBSD__ + + #include <machine/apm_bios.h> ++#include "acpi-freebsd.h" ++ ++struct acpi_info acpiinfo; ++gboolean using_acpi; ++int acpi_count; ++struct apm_info apminfo; ++ ++gboolean acpi_freebsd_read(struct apm_info *apminfo, struct acpi_info *acpiinfo); + + #define APMDEVICE "/dev/apm" + +@@ -86,32 +94,48 @@ + FreeBSD. Each time this functions is called (once every second) + the APM device is opened, read from and then closed. + */ +- struct apm_info apminfo; + int fd; + + if (DEBUG) g_print("apm_readinfo() (FreeBSD)\n"); + +- fd = open(APMDEVICE, O_RDONLY); +- if (fd == -1) +- { +- pm_initialised = 0; +- return ERR_OPEN_APMDEV; ++ if (using_acpi) { ++ fd = -1; ++ if (acpi_count <= 0) { ++ acpi_count = 30; ++ acpi_freebsd_read(&apminfo, &acpiinfo); ++ } ++ acpi_count--; + } ++ else { ++ fd = open(APMDEVICE, O_RDONLY); ++ if (fd == -1) { ++ return ERR_OPEN_APMDEV; ++ } + +- if (ioctl(fd, APMIO_GETINFO, &apminfo) == -1) +- err(1, "ioctl(APMIO_GETINFO)"); ++ if (ioctl(fd, APMIO_GETINFO, &apminfo) == -1) ++ err(1, "ioctl(APMIO_GETINFO)"); + +- close(fd); ++ close(fd); + +- if(apminfo.ai_status == 0) +- return ERR_APM_E; ++ if(apminfo.ai_status == 0) ++ return ERR_APM_E; ++ ++ } ++ ++ if (using_acpi) { ++ acpi_process_event(&acpiinfo); ++ acpi_freebsd_read(&apminfo, &acpiinfo); ++ } + + status->present = TRUE; + status->on_ac_power = apminfo.ai_acline ? 1 : 0; + status->state = apminfo.ai_batt_stat; + status->percent = apminfo.ai_batt_life; + status->charging = (status->state == 3) ? TRUE : FALSE; +- status->minutes = apminfo.ai_batt_time; ++ if (using_acpi) ++ status->minutes = apminfo.ai_batt_time; ++ else ++ status->minutes = (int) (apminfo.ai_batt_time/60.0); + + return NULL; + } +@@ -339,6 +363,13 @@ + G_IO_IN | G_IO_ERR | G_IO_HUP, + acpi_callback, NULL); + } ++#elif defined(__FreeBSD__) ++ if (acpi_freebsd_init(&acpiinfo)) { ++ using_acpi = TRUE; ++ acpi_count = 0; ++ } ++ else ++ using_acpi = FALSE; + #endif + pm_initialised = 1; + +@@ -360,6 +391,10 @@ + g_source_remove(acpiwatch); + acpiwatch = 0; + acpi_linux_cleanup(&acpiinfo); ++ } ++#elif defined(__FreeBSD__) ++ if (using_acpi) { ++ acpi_freebsd_cleanup(&acpiinfo); + } + #endif + +--- battstat/acpi-freebsd.c.orig Mon Feb 28 01:41:08 2005 ++++ battstat/acpi-freebsd.c Mon Feb 28 03:00:11 2005 +@@ -0,0 +1,206 @@ +/* battstat A GNOME battery meter for laptops. + * Copyright (C) 2000 by Jörgen Pehrson <jp@spektr.eu.org> + * @@ -125,7 +228,7 @@ + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * -+ $Id: patch-battstat-acpi,v 1.12 2005-02-16 08:02:18 marcus Exp $ ++ $Id: patch-battstat-acpi,v 1.13 2005-02-28 08:02:03 marcus Exp $ + */ + +/* @@ -151,7 +254,6 @@ +#include <glib.h> + +#include <dev/acpica/acpiio.h> -+#include <contrib/dev/acpica/acpi.h> + +#include "acpi-freebsd.h" + @@ -315,106 +417,3 @@ + return TRUE; +} +#endif ---- battstat/power-management.c.orig Thu Jan 13 23:06:40 2005 -+++ battstat/power-management.c Wed Feb 16 02:58:10 2005 -@@ -76,6 +76,14 @@ - #ifdef __FreeBSD__ - - #include <machine/apm_bios.h> -+#include "acpi-freebsd.h" -+ -+struct acpi_info acpiinfo; -+gboolean using_acpi; -+int acpi_count; -+struct apm_info apminfo; -+ -+gboolean acpi_freebsd_read(struct apm_info *apminfo, struct acpi_info *acpiinfo); - - #define APMDEVICE "/dev/apm" - -@@ -86,32 +94,48 @@ - FreeBSD. Each time this functions is called (once every second) - the APM device is opened, read from and then closed. - */ -- struct apm_info apminfo; - int fd; - - if (DEBUG) g_print("apm_readinfo() (FreeBSD)\n"); - -- fd = open(APMDEVICE, O_RDONLY); -- if (fd == -1) -- { -- pm_initialised = 0; -- return ERR_OPEN_APMDEV; -+ if (using_acpi) { -+ fd = -1; -+ if (acpi_count <= 0) { -+ acpi_count = 30; -+ acpi_freebsd_read(&apminfo, &acpiinfo); -+ } -+ acpi_count--; - } -+ else { -+ fd = open(APMDEVICE, O_RDONLY); -+ if (fd == -1) { -+ return ERR_OPEN_APMDEV; -+ } - -- if (ioctl(fd, APMIO_GETINFO, &apminfo) == -1) -- err(1, "ioctl(APMIO_GETINFO)"); -+ if (ioctl(fd, APMIO_GETINFO, &apminfo) == -1) -+ err(1, "ioctl(APMIO_GETINFO)"); - -- close(fd); -+ close(fd); - -- if(apminfo.ai_status == 0) -- return ERR_APM_E; -+ if(apminfo.ai_status == 0) -+ return ERR_APM_E; -+ -+ } -+ -+ if (using_acpi) { -+ acpi_process_event(&acpiinfo); -+ acpi_freebsd_read(&apminfo, &acpiinfo); -+ } - - status->present = TRUE; - status->on_ac_power = apminfo.ai_acline ? 1 : 0; - status->state = apminfo.ai_batt_stat; - status->percent = apminfo.ai_batt_life; - status->charging = (status->state == 3) ? TRUE : FALSE; -- status->minutes = apminfo.ai_batt_time; -+ if (using_acpi) -+ status->minutes = apminfo.ai_batt_time; -+ else -+ status->minutes = (int) (apminfo.ai_batt_time/60.0); - - return NULL; - } -@@ -339,6 +363,13 @@ - G_IO_IN | G_IO_ERR | G_IO_HUP, - acpi_callback, NULL); - } -+#elif defined(__FreeBSD__) -+ if (acpi_freebsd_init(&acpiinfo)) { -+ using_acpi = TRUE; -+ acpi_count = 0; -+ } -+ else -+ using_acpi = FALSE; - #endif - pm_initialised = 1; - -@@ -360,6 +391,10 @@ - g_source_remove(acpiwatch); - acpiwatch = 0; - acpi_linux_cleanup(&acpiinfo); -+ } -+#elif defined(__FreeBSD__) -+ if (using_acpi) { -+ acpi_freebsd_cleanup(&acpiinfo); - } - #endif - |