diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-12-14 17:07:41 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 2001-12-14 17:07:41 +0000 |
commit | 5e9d0cca09bc5a849c9bcbe62ef94688fe3750d2 (patch) | |
tree | fdc92549e0c3583325f710aff4b1d691255c29f8 /sys/arch/i386 | |
parent | fb6e2e1a056a6f631c29e9cd2c48782c529bfd17 (diff) |
on some sony vaios (con dios) battery life is reported
in big endian order, swap if flags was given.
reported by: Hans-Joerg Hoexer <Hans-Joerg.Hoexer@yerbouti.franken.de>
Diffstat (limited to 'sys/arch/i386')
-rw-r--r-- | sys/arch/i386/i386/apm.c | 17 | ||||
-rw-r--r-- | sys/arch/i386/include/apmvar.h | 3 |
2 files changed, 14 insertions, 6 deletions
diff --git a/sys/arch/i386/i386/apm.c b/sys/arch/i386/i386/apm.c index 1cd2521536b..325a0f5ba2b 100644 --- a/sys/arch/i386/i386/apm.c +++ b/sys/arch/i386/i386/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.49 2001/08/18 06:08:08 mickey Exp $ */ +/* $OpenBSD: apm.c,v 1.50 2001/12/14 17:07:40 mickey Exp $ */ /*- * Copyright (c) 1998-2001 Michael Shalayeff. All rights reserved. @@ -306,10 +306,13 @@ apm_power_print (sc, regs) printf("unknown"); if (BATT_FLAGS(regs) & APM_BATT_FLAG_CHARGING) printf(", charging"); - if (BATT_REM_VALID(regs)) + if (BATT_REM_VALID(regs)) { + int life = BATT_REMAINING(regs); + if (sc->sc_flags & APM_BEBATT) + life = swap16(life); printf(", estimated %d:%02d hours", - BATT_REMAINING(regs) / 60, - BATT_REMAINING(regs) % 60); + life / 60, life % 60); + } } } @@ -1082,8 +1085,12 @@ apmioctl(dev, cmd, data, flag, p) powerp->battery_state = APM_BATTERY_ABSENT; else powerp->battery_state = APM_BATT_UNKNOWN; - if (BATT_REM_VALID(®s)) + if (BATT_REM_VALID(®s)) { powerp->minutes_left = BATT_REMAINING(®s); + if (sc->sc_flags & APM_BEBATT) + powerp->minutes_left = + swap16(powerp->minutes_left); + } } } else { apm_perror("ioctl get power status", ®s); diff --git a/sys/arch/i386/include/apmvar.h b/sys/arch/i386/include/apmvar.h index 23ec88eab43..1703c833ac1 100644 --- a/sys/arch/i386/include/apmvar.h +++ b/sys/arch/i386/include/apmvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: apmvar.h,v 1.13 2001/08/18 06:08:08 mickey Exp $ */ +/* $OpenBSD: apmvar.h,v 1.14 2001/12/14 17:07:40 mickey Exp $ */ /* * Copyright (c) 1995 John T. Kohl @@ -51,6 +51,7 @@ #define APM_MINOR(f) ((f) & 0xff) #define APM_VERMASK 0x0000ffff #define APM_NOCLI 0x00010000 +#define APM_BEBATT 0x00020000 /* APM error codes */ #define APM_ERR_CODE(regs) (((regs)->ax & 0xff00) >> 8) |