diff options
author | Nikolay Sturm <sturm@cvs.openbsd.org> | 2005-11-23 08:02:59 +0000 |
---|---|---|
committer | Nikolay Sturm <sturm@cvs.openbsd.org> | 2005-11-23 08:02:59 +0000 |
commit | 319a8520491f8cffb4982572d824150e1857c383 (patch) | |
tree | a5d8ba3811a1c63e2cb158d0e9aa1cf69dec3a71 /usr.sbin/apm | |
parent | 2609c36d428c78eda3c28cef167ca0374334ebe7 (diff) |
permit apmd to run on systems without apm support
let apmd control hw.setperf manually or dynamically
tested by Chris Kuethe and beck@, 'get it in' deraadt@
Diffstat (limited to 'usr.sbin/apm')
-rw-r--r-- | usr.sbin/apm/apm.8 | 23 | ||||
-rw-r--r-- | usr.sbin/apm/apm.c | 37 |
2 files changed, 55 insertions, 5 deletions
diff --git a/usr.sbin/apm/apm.8 b/usr.sbin/apm/apm.8 index af0188211cb..3ecd14f5a81 100644 --- a/usr.sbin/apm/apm.8 +++ b/usr.sbin/apm/apm.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: apm.8,v 1.21 2005/11/15 01:27:58 jmc Exp $ +.\" $OpenBSD: apm.8,v 1.22 2005/11/23 08:02:58 sturm Exp $ .\" .\" Copyright (c) 1996 John T. Kohl .\" All rights reserved. @@ -38,7 +38,7 @@ .Op Fl f Ar sockname .Br .Nm apm -.Op Fl ablmSsvz +.Op Fl AabHLlmPSsvz .Op Fl f Ar sockname .Sh DESCRIPTION .Nm @@ -52,6 +52,10 @@ displays the current power management state in verbose form. .Pp The options are as follows: .Bl -tag -width Ds +.It Fl A +Set +.Xr apmd 8 +to automatic performance adjustment mode. .It Fl a Display the external charger (A/C status). 0 means disconnected, 1 @@ -65,10 +69,25 @@ Set the name of the socket via which to contact .Xr apmd 8 to .Pa sockname . +.It Fl H +Set +.Xr apmd 8 +to manual performance adjustment mode and +.Va hw.setperf +to 100. +.It Fl L +Set +.Xr apmd 8 +to manual performance adjustment mode and +.Va hw.setperf +to 0. .It Fl l Display the estimated battery lifetime (in percent). .It Fl m Display the estimated battery lifetime (in minutes). +.It Fl P +Display the performance adjustment mode. +0 means uninitialized, 1 means manual, and 2 means automatic mode. .It Fl S Put the system into stand-by (light sleep) mode. .It Fl s diff --git a/usr.sbin/apm/apm.c b/usr.sbin/apm/apm.c index f6a7918a5bf..334384b6d2f 100644 --- a/usr.sbin/apm/apm.c +++ b/usr.sbin/apm/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.12 2005/11/15 01:25:48 jmc Exp $ */ +/* $OpenBSD: apm.c,v 1.13 2005/11/23 08:02:58 sturm Exp $ */ /* * Copyright (c) 1996 John T. Kohl @@ -58,7 +58,7 @@ int send_command(int fd, struct apm_command *cmd, struct apm_reply *reply); void usage(void) { - fprintf(stderr,"usage: %s [-ablmSsvz] [-f sockname]\n", + fprintf(stderr,"usage: %s [-ablmPSsvz] [-f sockname] [-A | -L | -H]\n", __progname); exit(1); } @@ -142,13 +142,14 @@ main(int argc, char *argv[]) int dopct = FALSE; int dobstate = FALSE; int domin = FALSE; + int doperf = FALSE; int verbose = FALSE; int ch, fd, rval; enum apm_action action = NONE; struct apm_command command; struct apm_reply reply; - while ((ch = getopt(argc, argv, "lmbvasSzf:")) != -1) { + while ((ch = getopt(argc, argv, "AHLlmbvaPsSzf:")) != -1) { switch (ch) { case 'v': verbose = TRUE; @@ -166,6 +167,21 @@ main(int argc, char *argv[]) usage(); action = STANDBY; break; + case 'A': + if (action != NONE) + usage(); + action = SETPERF_AUTO; + break; + case 'H': + if (action != NONE) + usage(); + action = SETPERF_HIGH; + break; + case 'L': + if (action != NONE) + usage(); + action = SETPERF_LOW; + break; case 's': if (action != NONE && action != GETSTATUS) usage(); @@ -196,6 +212,12 @@ main(int argc, char *argv[]) doac = TRUE; action = GETSTATUS; break; + case 'P': + if (action != NONE && action != GETSTATUS) + usage(); + doperf = TRUE; + action = GETSTATUS; + break; default: usage(); } @@ -210,6 +232,7 @@ main(int argc, char *argv[]) case NONE: action = GETSTATUS; verbose = doac = dopct = dobstate = dostatus = domin = TRUE; + doperf = TRUE; /* fallthrough */ case GETSTATUS: if (fd == -1) { @@ -222,6 +245,9 @@ main(int argc, char *argv[]) /* fallthrough */ case SUSPEND: case STANDBY: + case SETPERF_LOW: + case SETPERF_HIGH: + case SETPERF_AUTO: command.action = action; break; default: @@ -254,6 +280,8 @@ main(int argc, char *argv[]) reply.batterystate.ac_state); if (dostatus) printf("1\n"); + if (doperf) + printf("%d\n", reply.perfstate); break; } if (dobstate) @@ -288,6 +316,9 @@ main(int argc, char *argv[]) if (doac) printf("A/C adapter state: %s\n", ac_state(reply.batterystate.ac_state)); + if (doperf) + printf("Performance state: %s\n", + perf_state(reply.perfstate)); if (dostatus) printf("Power management enabled\n"); break; |