diff options
author | Markus Brueffer <markus@FreeBSD.org> | 2009-11-12 23:02:44 +0000 |
---|---|---|
committer | Markus Brueffer <markus@FreeBSD.org> | 2009-11-12 23:02:44 +0000 |
commit | 9cecc370773de8c53106e137f94424471dd01ef9 (patch) | |
tree | 01b75951415db7d0acd91be43d7203ab3430c980 /deskutils/tpb/files | |
parent | a41c9013b7d6443e778275a29d34e2d860be6fef (diff) | |
download | ports-9cecc370773de8c53106e137f94424471dd01ef9.tar.gz ports-9cecc370773de8c53106e137f94424471dd01ef9.zip |
- Make tpb work if ACPI is not being used as requested by a user. In this case
nvram(4) and apm(4) are being used instead of acpi_ibm(4) to get the required
data.
- Bump PORTREVISION
Notes
Notes:
svn path=/head/; revision=244182
Diffstat (limited to 'deskutils/tpb/files')
-rw-r--r-- | deskutils/tpb/files/patch-man-tpb.1 | 13 | ||||
-rw-r--r-- | deskutils/tpb/files/patch-src-cfg.c | 17 | ||||
-rw-r--r-- | deskutils/tpb/files/patch-src-tpb.c | 78 |
3 files changed, 75 insertions, 33 deletions
diff --git a/deskutils/tpb/files/patch-man-tpb.1 b/deskutils/tpb/files/patch-man-tpb.1 index ba4e90938204..755aee1d3cc3 100644 --- a/deskutils/tpb/files/patch-man-tpb.1 +++ b/deskutils/tpb/files/patch-man-tpb.1 @@ -1,5 +1,5 @@ ---- man/tpb.1.orig Mon Dec 5 11:01:51 2005 -+++ man/tpb.1 Mon Dec 5 11:06:07 2005 +--- man/tpb.1.orig 2005-07-25 10:40:53.000000000 +0200 ++++ man/tpb.1 2009-11-12 23:50:29.000000000 +0100 @@ -7,7 +7,7 @@ With TPB it is possible to bind a program to the ThinkPad, Mail, Home and Search button. TPB can also run a callback program on each state change with the changed state and the new state as options. @@ -18,17 +18,16 @@ .TP \(bu configuration in $HOME/.tpbrc -@@ -121,7 +121,8 @@ +@@ -121,7 +121,7 @@ .TP 8 .B NVRAM Should define the nvram device from where the information about the key states -is read. Default is to try /dev/nvram, followed by /dev/misc/nvram. -+is read. Default is to try /dev/nvram, followed by /dev/misc/nvram. This has -+no effect on FreeBSD, since it uses the acpi_ibm(4) driver instead. ++is read. Default is to try /dev/nvram. .TP 8 .B POLLTIME Defines the delay between polls in microseconds. -@@ -332,14 +333,16 @@ +@@ -332,14 +332,18 @@ Possible values are left, center and right. Default is left. .SH "NOTES" @@ -39,6 +38,8 @@ The device file could be created with \'mknod /dev/nvram c 10 144\' +On FreeBSD you have to load the acpi_ibm(4) driver prior to using TPB. ++If ACPI and in turn acpi_ibm(4) is not available, nvram(4) and apm(4) ++are being used. + This program was developed on a Thinkpad Model T21. .SH EXAMPLE diff --git a/deskutils/tpb/files/patch-src-cfg.c b/deskutils/tpb/files/patch-src-cfg.c new file mode 100644 index 000000000000..c241d865e5b0 --- /dev/null +++ b/deskutils/tpb/files/patch-src-cfg.c @@ -0,0 +1,17 @@ +--- src/cfg.c.orig 2009-11-12 09:26:15.000000000 +0100 ++++ src/cfg.c 2009-11-12 08:33:55.000000000 +0100 +@@ -1548,12 +1548,14 @@ + _exit(1); + } + if((fdsc=open(cfg->nvram, O_RDONLY|O_NONBLOCK) == -1) && errno == ENOENT) { ++#ifndef __FreeBSD__ + /* Try devfs device */ + if((cfg->nvram=strdup(DEFAULT_NVRAMDEV_DEVFS)) == NULL) { + fputs(_("Not enough memory"),stderr); + _exit(1); + } + fdsc = open(cfg->nvram, O_RDONLY|O_NONBLOCK); ++#endif + } + + if(fdsc != -1) { diff --git a/deskutils/tpb/files/patch-src-tpb.c b/deskutils/tpb/files/patch-src-tpb.c index 7b4768301fe8..37d5926afd08 100644 --- a/deskutils/tpb/files/patch-src-tpb.c +++ b/deskutils/tpb/files/patch-src-tpb.c @@ -1,27 +1,31 @@ ---- src/tpb.c.orig Sun Aug 22 15:45:11 2004 -+++ src/tpb.c Mon Jun 13 17:31:34 2005 -@@ -34,6 +34,10 @@ +--- src/tpb.c.orig 2005-07-18 16:15:59.000000000 +0200 ++++ src/tpb.c 2009-11-12 09:51:09.000000000 +0100 +@@ -34,6 +34,14 @@ #include <unistd.h> #include "config.h" +#ifdef __FreeBSD__ ++#include <sys/file.h> ++#include <sys/ioctl.h> ++#include <sys/types.h> +#include <sys/sysctl.h> ++#include <machine/apm_bios.h> +#endif + #if ENABLE_NLS #include <libintl.h> #endif /* ENABLE_NLS */ -@@ -163,6 +167,9 @@ +@@ -161,6 +169,9 @@ /* to initialize struct */ memset(&last_thinkpad_state, 0x00, sizeof(t_thinkpad_state)); if(get_nvram_state(&thinkpad_state) != 0) { +#ifdef __FreeBSD__ -+ fprintf(stderr, _("acpi_ibm(4) driver not loaded. Exiting...")); ++ fprintf(stderr, _("Neither acpi_ibm(4) nor nvram(4) driver loaded. Exiting...")); +#endif _exit(1); } if(cfg.apm == STATE_ON) { -@@ -449,6 +456,25 @@ +@@ -449,6 +460,25 @@ #endif /* HAVE_LIBXOSD */ } /* }}} */ @@ -47,24 +51,24 @@ /* determine the state of display {{{ */ if((thinkpad_state.display_toggle != last_thinkpad_state.display_toggle || thinkpad_state.display_state != last_thinkpad_state.display_state) && -@@ -972,6 +998,7 @@ - /* get the current state from the nvram */ +@@ -981,6 +1011,11 @@ int get_nvram_state(t_thinkpad_state *thinkpad_state) /* {{{ */ { -+#ifndef __FreeBSD__ static int fdsc = -1; /* -1 -> file not opened */ ++#ifdef __FreeBSD__ ++ u_int n = 0; ++ size_t len = sizeof(n); ++ if ( fdsc != -1 || sysctlbyname("dev.acpi_ibm.0.hotkey", &n, &len, NULL, 0) == -1 ) { ++#endif unsigned char buffer[114]; struct { -@@ -1030,13 +1057,52 @@ - thinkpad_state->mute_toggle = (thinkpad_state->mute_toggle & ~0x01) | (( buffer[0x60] & 0x40) >> 6); - thinkpad_state->powermgt_ac = (( buffer[0x39] & 0x07) ); + int pos; +@@ -1040,13 +1075,51 @@ thinkpad_state->powermgt_battery = (( buffer[0x39] & 0x38) >> 3); -+#else -+ u_int n = 0; -+ size_t len = sizeof(n); -+ if ( sysctlbyname("dev.acpi_ibm.0.hotkey", &n, &len, NULL, 0) == -1 ) -+ return -1; + return 0; ++#ifdef __FreeBSD__ ++ } + thinkpad_state->thinkpad_toggle = (thinkpad_state->thinkpad_toggle & ~0x01) | (( n & (1<<3)) >> 3); + thinkpad_state->zoom_toggle = (thinkpad_state->zoom_toggle & ~0x01) | (( n & (1<<4)) >> 4); + thinkpad_state->display_toggle = (thinkpad_state->display_toggle & ~0x01) | (( n & (1<<6)) >> 6); @@ -97,18 +101,22 @@ + if ( sysctlbyname("dev.acpi_ibm.0.mute", &n, &len, NULL, 0) == -1 ) + return -1; + thinkpad_state->mute_toggle = n; ++ ++ return 0; +#endif - return 0; } /* }}} */ /* get the current state from the apm subsystem */ int get_apm_state(t_thinkpad_state *thinkpad_state) /* {{{ */ { -+#ifndef __FreeBSD__ - unsigned int i; +- unsigned int i; static int fdsc = -1; /* -1 -> file not opened */ ++#ifndef __FreeBSD__ ++ unsigned int i; char buffer[38]; -@@ -1114,7 +1180,15 @@ + char *tokens[9]; + +@@ -1122,7 +1195,28 @@ thinkpad_state->ac_state = STATE_ON; break; } @@ -116,31 +124,47 @@ + u_long addr; + size_t len = sizeof(addr); + -+ if ( sysctlbyname("hw.acpi.acline", &addr, &len, NULL, 0) == -1 ) -+ return -1; ++ if ( fdsc != -1 || sysctlbyname("hw.acpi.acline", &addr, &len, NULL, 0) == -1 ) { ++ // Try APM ++ if(fdsc == -1) { /* if not already opened, open apm */ ++ if((fdsc = open("/dev/apm", O_RDONLY)) == -1) ++ return -1; ++ } ++ struct apm_info info; ++ if (ioctl(fdsc, APMIO_GETINFO, &info) == -1) ++ return -1; ++ ++ if (info.ai_acline > 2) ++ return -1; ++ ++ addr = info.ai_acline; ++ } + thinkpad_state->ac_state = (addr == 1) ? STATE_ON : STATE_OFF; +#endif return 0; } /* }}} */ -@@ -1276,6 +1350,12 @@ +@@ -1285,6 +1379,13 @@ /* only use writeback to nvram when cfg.mixersteps is different from DEFAULT_MIXERSTEPS */ if(cfg.mixersteps != DEFAULT_MIXERSTEPS) { +#ifdef __FreeBSD__ + u_int n = thinkpad_state->volume_level; + -+ if (sysctlbyname("dec.acpi_ibm.0.volume", NULL, NULL, &n, sizeof(n))) ++ if (sysctlbyname("dec.acpi_ibm.0.volume", NULL, NULL, &n, sizeof(n)) != 0) + fprintf(stderr, _("Unable to set volume sysctl")); -+#else ++ else { ++#endif /* open nvram */ if((fdsc = open(cfg.nvram, O_RDWR|O_NONBLOCK)) == -1) { fprintf(stderr, _("Unable to open device %s: "), cfg.nvram); -@@ -1317,8 +1397,8 @@ +@@ -1326,8 +1427,10 @@ } close(fdsc); ++#ifdef __FreeBSD__ ++ } +#endif } - |