[ltp] Re: Generic battery interface

Michael Olbrich linux-thinkpad@linux-thinkpad.org
Mon, 31 Jul 2006 18:37:19 +0000


--s2ZSL+KKDSLx8OML
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Jul 31, 2006 at 06:18:12PM +0300, Shem Multinymous wrote:
> On 7/31/06, Michael Olbrich <michael.olbrich@gmx.net> wrote:
> >Hmmm, that looks good for most cases. But how would you handle
> >starting/stoping laoding/draining the battery?
> >That usually results in values jumping from/to 0. A gui would want to
> >show such a change immediately while otherwise keeping a slow update
> >rate. Maybe some kind of threshhold parameter? "send an input-ready
> >immediatelly if the value changes by more than x%".
>=20
> Changes by more than x% compared to what?
>=20
> The value at the time of the ioctl()? This might completely miss a
> change that happened between the previous read() and the ioctl().
>=20
> The value at the time of the last read()? Then the kernel
> driver+infrastructure will need to keep track of the latest readout
> done by each app. That's pretty heavy.
>=20
> So what semantics make sense?

Well, the kernel is polling the hardware and caches the last value for
O_NONBLOCKing anyway. So we already have two values to compare.
And keeping the latest readout for each app isn't that heavy. After all
we already have to keep track of the timeouts for each app.

Another way to handle this:
A lot of applications are interrested in changes. It would be perfectly
reasonable for a poll() to block for over 1 minute while the value
fluctuates with changes less than e.g. 1%. As soon as the change
(compared to the last readout) exceds this threshhold poll() returns
immediatelly. This could of course be combined with the proposed
timeouts.

m


--s2ZSL+KKDSLx8OML
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFEzk3f3fK8vSqP5HsRAmyjAJ9e9Jj1FuyNDNIrn8HwZKH+XWTBkgCfRvst
KsyYC1ZbineiYaJ9X81HC74=
=BlSB
-----END PGP SIGNATURE-----

--s2ZSL+KKDSLx8OML--