[gpm] Fixing laptop brightness control



Hello list,

I'd like to fix GPM's laptop brightness control.

First, a description of my hardware: a powerbook g4, with an nvidia
card. The brightness is controlled by a kernel module interacting with
the video card, exporting its interface via sysfs as a standard device
of class "backlight". My keyboard has two buttons to raise or lower the
backlight level. When I press them, my backlight does indeed go up and
down, and the gtk+ backlight thingie pops up. Given that the device is
controllable via sysfs, I'll assume that it's HAL controlling the
brightness.

Here is my principle regarding the backlight: "The user knows exactly
how bright the screen should be." If the sun goes down, I lower the
brightness with the keys. If I'm in a bar and move somewhere where
there's less light, I raise the brightness.

This has all worked fine in the past, until the (otherwise excellent and
nifty) automatic backlight dimming work that Anholt did. It's quite fine
for G-P-M to lower backlight levels in times of inactivity, but it
should raise them back to the levels that I had set them at previously.

The current case is that it goes back to whatever level that is set in
GConf, which is only controlled via the g-p-m preferences page. If GConf
is where this information has to go, well, let's make the user's choices
get stored in GConf.

This should work whether the user is on AC power or on battery. In this
regard, the current implementation is a bit tricky -- there are only two
knobs, GPM_CONF_BACKLIGHT_BRIGHTNESS_AC and
GPM_CONF_BACKLIGHT_BRIGHTNESS_BATT.

The AC case is easy: pressing a button should cause BRIGHTNESS_AC to be
set.

The battery case is different: BRIGHTNESS_BATT is actually not a level,
it is a percent by which to reduce BRIGHTNESS_AC. One algorithm we could
use would be the following, where CUR is the new brightness percentage
that the user has selected via the brightness buttons:

  if CUR >= BRIGHTNESS_AC:
    BRIGHTNESS_AC = CUR  # Don't dim when the user plugs in AC power
    BRIGHTNESS_BATT = 0%  # Set battery brightness = ac brightness
  else
    BRIGHTNESS_BATT = (BRIGHTNESS_AC - CUR) / BRIGHTNESS_AC * 100

Alternately we could choose some other representation for
BRIGHTNESS_BATT. Not very important though.

Thoughts?

Cheers,

Andy
-- 
http://wingolog.org/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]