Subject: Re: power management and idle detection on non-x86
To: Jared D. McNeill <jmcneill@invisible.ca>
From: Michael Lorenz <macallan@netbsd.org>
List: tech-kern
Date: 05/07/2006 20:26:25
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

>> I've been working to get some sort of power management into my 
>> sparcbook for a while now and apart from powerhooks in many device 
>> drivers there are a few other things missing.
>> First, we need a way to know when the machine is idle so we can dim 
>> backlight at some point, or fall asleep. What I'd like to have is a 
>> bunch of 'idle timers' - just write the current timestamp into a more 
>> or less global variable whenever the mouse is moved, some key is 
>> pressed etc., probably keep different counters for different devices. 
>> With this we could detect 'idleness' by just comparing these 
>> variables to current time, if enough of them differ by some 
>> predefined value we can take actions. On PCs this is probably handled 
>> by the APM BIOS but on macppc or sparc we don't have anything like 
>> that so we need our own.

> wscons seems like the ideal place to handle this.

Yeah, it's getting all the relevant input anyway.

> Low level hw drivers should be able to register callbacks for certain 
> actions ("dim/standby/suspend display", etc).

Agreed, so far pnozz and tctrl talk to each other in a not exactly 
generic way ( since tctrl controls the backlight but pnozz needs to 
support the ioctl for it ) Maybe something similar to powerhooks? Hmm, 
Cherry wanted to extend the powerhooks interface.

> Now, policy needs to be set in userland.

Of course. But it shouldn't depend on something like X and it should 
probably work reasonably without userland intervention.

> Also, if you sleep, you want to notify powerd that you want to go to 
> sleep so it can run its sleep scripts before powering off -- don't do 
> this directly from the kernel.

Of course. So we can power down / reconfigure / reconnect network 
interfaces and such.

> Also, x86 is interested in this for ACPI. I'd be willing to work with 
> you on this.

Yeah,  wants to know when we're going to sleep / wake up so it can do 
its voodoo with the graphics chip(s). I think something like that is in 
place already but probably linux-specific.

>> So, before I'm wasting my time inventing the wheel the 5th time - do 
>> we have something like this somewhere in the kernel? Should it be 
>> integrated with powerd? What about powerd vs. apmd? Their scopes seem 
>> to overlap quite a bit.
> apmd is dead; the future is powerd.

Ok, that's what my sparcbook is running.

have fun
Michael
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)

iQEVAwUBRF6QMcpnzkX8Yg2nAQL+EggAuuc8K1EsOdnE5hVBCHsyU2exzP2VVFJ3
N/4pb/JeSpQvVGC83Iy2vSWqS2LD/k52adXKQdOrJFhlBmnjgALULhg2oPHGQsn6
wNXO0K2+60SDddlOdu4zWuib9DE00m3yQ0HXyChK0oQ4P8p21UBwML+h/gF5+Nhl
Fz4CLkfEYZRqM5tRtF0CUNSh2yv4iTcEImWFvYTFdRTx4KxY55AKHe2pMU/L8h9Q
iKnMykHSpAclyajqZ8vdhlY8mLZP/hzJhhdHcJ2l3D6FeI9n1fYj9vsA6dT6bBsn
QnCpMm0uEnKeelQXbRkUDZRN7CE55SWHbKBNQQxXaPFNMZJZUKxrRg==
=S5kp
-----END PGP SIGNATURE-----