From bf836a2509e77d1eb291b260ff089471eafd5942 Mon Sep 17 00:00:00 2001 From: Joe Marcus Clarke Date: Tue, 15 Mar 2005 04:46:31 +0000 Subject: [PATCH] Add battstat (ACPI only) support for amd64. Submitted by: Jung-uk Kim --- x11/gnome-applets/Makefile | 5 +- x11/gnome-applets/files/patch-aa | 2 +- x11/gnome-applets/files/patch-battstat-acpi | 69 +++++++++++++++++---- x11/gnomeapplets2/Makefile | 5 +- x11/gnomeapplets2/files/patch-aa | 2 +- x11/gnomeapplets2/files/patch-battstat-acpi | 69 +++++++++++++++++---- 6 files changed, 122 insertions(+), 30 deletions(-) diff --git a/x11/gnome-applets/Makefile b/x11/gnome-applets/Makefile index d2ee9028fc0f..01fcedea4a8f 100644 --- a/x11/gnome-applets/Makefile +++ b/x11/gnome-applets/Makefile @@ -7,6 +7,7 @@ PORTNAME= gnomeapplets2 PORTVERSION= 2.10.0 +PORTREVISION= 1 CATEGORIES= x11 gnome MASTER_SITES= ${MASTER_SITE_GNOME} MASTER_SITE_SUBDIR= sources/gnome-applets/2.10 @@ -45,7 +46,7 @@ FREEBSD_SYS?= /usr/src/sys .include -.if ${ARCH} != "i386" +.if ${ARCH} != "i386" && ${ARCH} != "amd64" CONFIGURE_ENV+= CFLAGS="${CFLAGS} -fPIC" PLIST_SUB= BATTERY="@comment " .else @@ -53,6 +54,7 @@ GCONF_SCHEMAS+= battstat.schemas PLIST_SUB= BATTERY="" .if ${OSVERSION} < 600019 +.if ${OSVERSION} < 503105 || ${OSVERSION} >= 600000 pre-everything:: @${ECHO_MSG} "" @${ECHO_MSG} " W A R N I N G" @@ -66,6 +68,7 @@ pre-everything:: @${ECHO_MSG} "" .endif .endif +.endif .if ${ARCH} != "i386" && ${ARCH} != "amd64" PLIST_SUB+= CPUFREQ="@comment " diff --git a/x11/gnome-applets/files/patch-aa b/x11/gnome-applets/files/patch-aa index 2a74a1ed8f2b..9e8038833e85 100644 --- a/x11/gnome-applets/files/patch-aa +++ b/x11/gnome-applets/files/patch-aa @@ -32,7 +32,7 @@ ;; # list of supported OS cores that do not use libapm - *-*-freebsd*|*-*-netbsd*|*-*-openbsd*) -+ i386-*-freebsd*|*-*-netbsd*|*-*-openbsd*) ++ i386-*-freebsd*|amd64-*-freebsd*|*-*-netbsd*|*-*-openbsd*) + if [ -n "${FREEBSD_SYS}" ]; then + ACPIINC="-I${FREEBSD_SYS}" + else diff --git a/x11/gnome-applets/files/patch-battstat-acpi b/x11/gnome-applets/files/patch-battstat-acpi index ebaa93f7e670..f34bd3cadc16 100644 --- a/x11/gnome-applets/files/patch-battstat-acpi +++ b/x11/gnome-applets/files/patch-battstat-acpi @@ -1,6 +1,6 @@ --- battstat/acpi-freebsd.h.orig Mon Sep 27 18:39:30 2004 +++ battstat/acpi-freebsd.h Mon Sep 27 18:39:30 2004 -@@ -0,0 +1,45 @@ +@@ -0,0 +1,56 @@ +/* + * Copyright (C) 2004 by Joe Marcus Clarke + * @@ -32,6 +32,17 @@ +#define ACPI_LIFE "hw.acpi.battery.life" +#define ACPI_STATE "hw.acpi.battery.state" + ++/* XXX: AMD64 does not have machine/apm_bios.h. */ ++#if !defined(__i386__) ++struct apm_info { ++ guint ai_acline; ++ guint ai_batt_stat; ++ guint ai_batt_life; ++ int ai_batt_time; ++ guint ai_status; ++}; ++#endif ++ +struct acpi_info { + gboolean ac_online; + int acpifd; @@ -106,11 +117,17 @@ }; --- 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__ ++++ battstat/power-management.c Mon Mar 14 19:53:13 2005 +@@ -73,9 +73,18 @@ + * the problem might be. This error message is not to be freed. + */ +-#ifdef __FreeBSD__ +- ++#if defined(__FreeBSD__) ++#if defined(__i386__) #include ++#endif +#include "acpi-freebsd.h" + +struct acpi_info acpiinfo; @@ -122,7 +139,7 @@ #define APMDEVICE "/dev/apm" -@@ -86,32 +94,48 @@ +@@ -86,32 +95,51 @@ FreeBSD. Each time this functions is called (once every second) the APM device is opened, read from and then closed. */ @@ -145,6 +162,7 @@ + acpi_count--; } + else { ++#if defined(__i386__) + fd = open(APMDEVICE, O_RDONLY); + if (fd == -1) { + return ERR_OPEN_APMDEV; @@ -157,14 +175,16 @@ - close(fd); + close(fd); ++ ++ if(apminfo.ai_status == 0) ++ return ERR_APM_E; ++#else ++ return ERR_OPEN_APMDEV; ++#endif ++ } - 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); @@ -183,7 +203,7 @@ return NULL; } -@@ -339,6 +363,13 @@ +@@ -339,6 +367,13 @@ G_IO_IN | G_IO_ERR | G_IO_HUP, acpi_callback, NULL); } @@ -197,7 +217,7 @@ #endif pm_initialised = 1; -@@ -360,6 +391,10 @@ +@@ -360,6 +395,10 @@ g_source_remove(acpiwatch); acpiwatch = 0; acpi_linux_cleanup(&acpiinfo); @@ -208,9 +228,30 @@ } #endif +--- battstat/properties.c.orig Fri Jan 14 23:38:18 2005 ++++ battstat/properties.c Mon Mar 14 19:49:26 2005 +@@ -27,7 +27,7 @@ + + #include + +-#ifdef __FreeBSD__ ++#if defined(__FreeBSD__) && defined(__i386__) + #include + #elif defined(__NetBSD__) || defined(__OpenBSD__) + #include +@@ -61,6 +61,9 @@ + #include + /*#include */ + ++#if defined(__FreeBSD__) && !defined(__i386__) ++#include "acpi-freebsd.h" ++#endif + #include "battstat.h" + + #ifndef gettext_noop --- 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 @@ +@@ -0,0 +1,208 @@ +/* battstat A GNOME battery meter for laptops. + * Copyright (C) 2000 by Jörgen Pehrson + * @@ -246,7 +287,9 @@ +#include +#include +#include ++#if defined(__i386__) +#include ++#endif +#include +#include +#include diff --git a/x11/gnomeapplets2/Makefile b/x11/gnomeapplets2/Makefile index d2ee9028fc0f..01fcedea4a8f 100644 --- a/x11/gnomeapplets2/Makefile +++ b/x11/gnomeapplets2/Makefile @@ -7,6 +7,7 @@ PORTNAME= gnomeapplets2 PORTVERSION= 2.10.0 +PORTREVISION= 1 CATEGORIES= x11 gnome MASTER_SITES= ${MASTER_SITE_GNOME} MASTER_SITE_SUBDIR= sources/gnome-applets/2.10 @@ -45,7 +46,7 @@ FREEBSD_SYS?= /usr/src/sys .include -.if ${ARCH} != "i386" +.if ${ARCH} != "i386" && ${ARCH} != "amd64" CONFIGURE_ENV+= CFLAGS="${CFLAGS} -fPIC" PLIST_SUB= BATTERY="@comment " .else @@ -53,6 +54,7 @@ GCONF_SCHEMAS+= battstat.schemas PLIST_SUB= BATTERY="" .if ${OSVERSION} < 600019 +.if ${OSVERSION} < 503105 || ${OSVERSION} >= 600000 pre-everything:: @${ECHO_MSG} "" @${ECHO_MSG} " W A R N I N G" @@ -66,6 +68,7 @@ pre-everything:: @${ECHO_MSG} "" .endif .endif +.endif .if ${ARCH} != "i386" && ${ARCH} != "amd64" PLIST_SUB+= CPUFREQ="@comment " diff --git a/x11/gnomeapplets2/files/patch-aa b/x11/gnomeapplets2/files/patch-aa index 2a74a1ed8f2b..9e8038833e85 100644 --- a/x11/gnomeapplets2/files/patch-aa +++ b/x11/gnomeapplets2/files/patch-aa @@ -32,7 +32,7 @@ ;; # list of supported OS cores that do not use libapm - *-*-freebsd*|*-*-netbsd*|*-*-openbsd*) -+ i386-*-freebsd*|*-*-netbsd*|*-*-openbsd*) ++ i386-*-freebsd*|amd64-*-freebsd*|*-*-netbsd*|*-*-openbsd*) + if [ -n "${FREEBSD_SYS}" ]; then + ACPIINC="-I${FREEBSD_SYS}" + else diff --git a/x11/gnomeapplets2/files/patch-battstat-acpi b/x11/gnomeapplets2/files/patch-battstat-acpi index ebaa93f7e670..f34bd3cadc16 100644 --- a/x11/gnomeapplets2/files/patch-battstat-acpi +++ b/x11/gnomeapplets2/files/patch-battstat-acpi @@ -1,6 +1,6 @@ --- battstat/acpi-freebsd.h.orig Mon Sep 27 18:39:30 2004 +++ battstat/acpi-freebsd.h Mon Sep 27 18:39:30 2004 -@@ -0,0 +1,45 @@ +@@ -0,0 +1,56 @@ +/* + * Copyright (C) 2004 by Joe Marcus Clarke + * @@ -32,6 +32,17 @@ +#define ACPI_LIFE "hw.acpi.battery.life" +#define ACPI_STATE "hw.acpi.battery.state" + ++/* XXX: AMD64 does not have machine/apm_bios.h. */ ++#if !defined(__i386__) ++struct apm_info { ++ guint ai_acline; ++ guint ai_batt_stat; ++ guint ai_batt_life; ++ int ai_batt_time; ++ guint ai_status; ++}; ++#endif ++ +struct acpi_info { + gboolean ac_online; + int acpifd; @@ -106,11 +117,17 @@ }; --- 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__ ++++ battstat/power-management.c Mon Mar 14 19:53:13 2005 +@@ -73,9 +73,18 @@ + * the problem might be. This error message is not to be freed. + */ +-#ifdef __FreeBSD__ +- ++#if defined(__FreeBSD__) ++#if defined(__i386__) #include ++#endif +#include "acpi-freebsd.h" + +struct acpi_info acpiinfo; @@ -122,7 +139,7 @@ #define APMDEVICE "/dev/apm" -@@ -86,32 +94,48 @@ +@@ -86,32 +95,51 @@ FreeBSD. Each time this functions is called (once every second) the APM device is opened, read from and then closed. */ @@ -145,6 +162,7 @@ + acpi_count--; } + else { ++#if defined(__i386__) + fd = open(APMDEVICE, O_RDONLY); + if (fd == -1) { + return ERR_OPEN_APMDEV; @@ -157,14 +175,16 @@ - close(fd); + close(fd); ++ ++ if(apminfo.ai_status == 0) ++ return ERR_APM_E; ++#else ++ return ERR_OPEN_APMDEV; ++#endif ++ } - 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); @@ -183,7 +203,7 @@ return NULL; } -@@ -339,6 +363,13 @@ +@@ -339,6 +367,13 @@ G_IO_IN | G_IO_ERR | G_IO_HUP, acpi_callback, NULL); } @@ -197,7 +217,7 @@ #endif pm_initialised = 1; -@@ -360,6 +391,10 @@ +@@ -360,6 +395,10 @@ g_source_remove(acpiwatch); acpiwatch = 0; acpi_linux_cleanup(&acpiinfo); @@ -208,9 +228,30 @@ } #endif +--- battstat/properties.c.orig Fri Jan 14 23:38:18 2005 ++++ battstat/properties.c Mon Mar 14 19:49:26 2005 +@@ -27,7 +27,7 @@ + + #include + +-#ifdef __FreeBSD__ ++#if defined(__FreeBSD__) && defined(__i386__) + #include + #elif defined(__NetBSD__) || defined(__OpenBSD__) + #include +@@ -61,6 +61,9 @@ + #include + /*#include */ + ++#if defined(__FreeBSD__) && !defined(__i386__) ++#include "acpi-freebsd.h" ++#endif + #include "battstat.h" + + #ifndef gettext_noop --- 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 @@ +@@ -0,0 +1,208 @@ +/* battstat A GNOME battery meter for laptops. + * Copyright (C) 2000 by Jörgen Pehrson + * @@ -246,7 +287,9 @@ +#include +#include +#include ++#if defined(__i386__) +#include ++#endif +#include +#include +#include