Calculate and use seconds of power remaining for smart battery types.
This commit is contained in:
parent
66ca62ad71
commit
2fd848709f
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: apm.c,v 1.12 2005/02/01 02:05:10 briggs Exp $ */
|
||||
/* $NetBSD: apm.c,v 1.13 2005/02/01 02:23:26 briggs Exp $ */
|
||||
/* $OpenBSD: apm.c,v 1.5 2002/06/07 07:13:59 miod Exp $ */
|
||||
|
||||
/*-
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: apm.c,v 1.12 2005/02/01 02:05:10 briggs Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: apm.c,v 1.13 2005/02/01 02:23:26 briggs Exp $");
|
||||
|
||||
#include "apm.h"
|
||||
|
||||
@ -351,13 +351,10 @@ apmioctl(dev, cmd, data, flag, p)
|
||||
power->battery_life = 0;
|
||||
} else if ((power->ac_state == APM_AC_ON) &&
|
||||
(batt.draw > 0)) {
|
||||
power->minutes_left =
|
||||
(((batt.max_charge - batt.cur_charge) * 3600) /
|
||||
batt.draw) / 60;
|
||||
power->minutes_left = batt.secs_remaining / 60;
|
||||
power->battery_state = APM_BATT_CHARGING;
|
||||
} else {
|
||||
power->minutes_left =
|
||||
((batt.cur_charge * 3600) / (-batt.draw)) / 60;
|
||||
power->minutes_left = batt.secs_remaining / 60;
|
||||
|
||||
/* XXX - Arbitrary */
|
||||
if (power->battery_life > 60) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pm_direct.c,v 1.21 2005/01/07 05:03:08 briggs Exp $ */
|
||||
/* $NetBSD: pm_direct.c,v 1.22 2005/02/01 02:23:26 briggs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1997 Takashi Hamada
|
||||
@ -38,7 +38,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: pm_direct.c,v 1.21 2005/01/07 05:03:08 briggs Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: pm_direct.c,v 1.22 2005/02/01 02:23:26 briggs Exp $");
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifndef ADB_DEBUG
|
||||
@ -1293,6 +1293,7 @@ pm_battery_info(int battery, struct pmu_battery_info *info)
|
||||
|
||||
info->flags = p.data[1];
|
||||
|
||||
info->secs_remaining = 0;
|
||||
switch (p.data[0]) {
|
||||
case 3:
|
||||
case 4:
|
||||
@ -1315,6 +1316,16 @@ pm_battery_info(int battery, struct pmu_battery_info *info)
|
||||
info->voltage = 0;
|
||||
break;
|
||||
}
|
||||
if (info->draw) {
|
||||
if (info->flags & PMU_PWR_AC_PRESENT && info->draw > 0) {
|
||||
info->secs_remaining =
|
||||
((info->max_charge - info->cur_charge) * 3600)
|
||||
/ info->draw;
|
||||
} else {
|
||||
info->secs_remaining =
|
||||
(info->cur_charge * 3600) / -info->draw;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user