diff options
author | iwasaki <iwasaki@FreeBSD.org> | 2002-03-04 18:46:13 +0000 |
---|---|---|
committer | iwasaki <iwasaki@FreeBSD.org> | 2002-03-04 18:46:13 +0000 |
commit | 3f245d8dd193f05b337f1358ec6b33ed212f9cc1 (patch) | |
tree | 8012c8174b9cc8503bad897aec51d04ec2c4490b /sys/kern | |
parent | 3fe10323bf98b7928a3f885f578ec703252ee6b7 (diff) | |
download | FreeBSD-src-3f245d8dd193f05b337f1358ec6b33ed212f9cc1.zip FreeBSD-src-3f245d8dd193f05b337f1358ec6b33ed212f9cc1.tar.gz |
Add generalized power profile code.
This makes other power-management system (APM for now) to be able to
generate power profile change events (ie. AC-line status changes), and
other kernel components, not only the ACPI components, can be notified
the events.
- move subroutines in acpi_powerprofile.c (removed) to kern/subr_power.c
- call power_profile_set_state() also from APM driver when AC-line
status changes
- add call-back function for Crusoe LongRun controlling on power
profile changes for a example
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/subr_power.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sys/kern/subr_power.c b/sys/kern/subr_power.c index d73958c..7c96c9e 100644 --- a/sys/kern/subr_power.c +++ b/sys/kern/subr_power.c @@ -28,6 +28,7 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/proc.h> #include <sys/power.h> @@ -74,3 +75,33 @@ power_pm_suspend(int state) power_pm_fn(POWER_CMD_SUSPEND, power_pm_arg, state); } +/* + * Power profile. + */ + +static int power_profile_state = POWER_PROFILE_PERFORMANCE; + +int +power_profile_get_state(void) +{ + return (power_profile_state); +} + +void +power_profile_set_state(int state) +{ + int changed; + + if (state != power_profile_state) { + power_profile_state = state; + changed = 1; + printf("system power profile changed to '%s'\n", + (state == POWER_PROFILE_PERFORMANCE) ? "performance" : "economy"); + } else { + changed = 0; + } + + if (changed) + EVENTHANDLER_INVOKE(power_profile_change); +} + |