g-p-m does not honor its configuration for LCD brightness levels after multiple unplug-replug from AC

Bug #215484 reported by Paulo J. S. Silva
34
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gnome-power-manager (Ubuntu)
Invalid
Medium
Unassigned
Nominated for Hardy by BandD

Bug Description

Binary package hint: gnome-power-manager

However I have noticed a problem that is easy to reproduce and is related to some of the posts above in bug #199522 (https://bugs.launchpad.net/bugs/199522):

1) Turn on the laptop on AC
2) After logging in unplug and replug the laptop to AC many times.

After each the unplug-replug cycle the final brightness is different, with a clear trend to decrease.

I have tried to delete my old g-p-m settings by deleting g-p-m directories in ~/.gnome2 and ~/.gconf without any improvement.

Revision history for this message
Karl Martin (klein-km) wrote :

I can confirm this bug on a Thinkpad T61 8889-2BG with Nvidia graphics card.
Gnome-power-manager restores the brightness after replugging to a slightly lower value than before unplugging. However, it is possible to increase the brightness to the maximum level with the brightness keys.

Revision history for this message
Karl Martin (klein-km) wrote :
Revision history for this message
pelle.k (pele2) wrote :

I'm having problems with "dim/restore" feature, and also the change between AC/battery mode.

Everytime it goes back up from "dim", it decreases until it hits some magic bottom. I've got a brightness range of 0-8. I adjust it to 7. then, let me illustrate;
idle > 7
dim > 4
idle > 6
dim > 4
idle > 5
dim > 4
idle > 5
dim > 4
idle > 5

And this is what happens when i adjust to 7 (idle) then pull the power and let it run on battery, then put the AC in again (repeatedly);
power > 7
battery > 4
power > 6
battery > 3
power > 5
battery > 2
power > 4
battery > 1
power > 3
battery > 0
power > 2
battery > 0
power > 2
battery > 0

Also, i have to adjust the brightness level myself at each reboot (i do it automatically in rc.local with "cat 7 > /sys/devices/virtual/backlight/acpi_video0/brightness).

gnome-power-manager:
  Installed: 2.22.1-1ubuntu4
  Candidate: 2.22.1-1ubuntu4
  Version table:
 *** 2.22.1-1ubuntu4 0
        500 http://us.archive.ubuntu.com hardy/main Packages
        100 /var/lib/dpkg/status

Changed in gnome-power-manager:
status: New → Confirmed
Revision history for this message
Øyvind Stegard (oyvindstegard) wrote :

I'm seeing the exact same problem on my Lenovo Thinkpad Z61m. The brightness is correctly dimmed when going from AC to battery, but is not fully restored to 100% after plugging the AC back in. It increases, but only up to level MAX-1 (90% or so, after *one* unplug/plug cycle). This results in the behaviour described in this bug report, where the total trend is overall decreasing brightness after many AC unplug/plug events. It is very easy to reproduce.

$ gconftool -a /apps/gnome-power-manager/backlight
 idle_dim_battery = true
 idle_brightness = 30
 dpms_method_battery = default
 dpms_method_ac = default
 idle_dim_time = 30
 brightness_battery = 70
 enable = true
 idle_dim_ac = false
 battery_reduce = true
 brightness_ac = 100

Revision history for this message
pelle.k (pele2) wrote :

I've traced down the problem to 04_brightness_events.patch, and built gpm without that patch (and 03_always_get_hw_backlight.patch), and it works much better.
Unfortunately, my C skills really suck, so i can't give you any help there :(
Just to be on the clear, you guys have no problem at bootup/login with gpm not restoring the brightness setting you had before?
Ted (i assume you are the maintainer of gpm?), how does gpm store AC brightness, because i don't see either level (AC/battery) saved in gconf?

I'll attach a gpm log of how the brightness decreases when shifting AC/battery.

Revision history for this message
Paulo J. S. Silva (pjssilva) wrote :

I have found out the problem. I'll use my laptop as an example. It has 7 brightness levels (from 0 to 6).

The default brightness parameters are brightness_ac=100, brightness_battery=70, idle_brightness=30.

Hence, if I start the system plugged, my LCD starts at level 6. Then I unplug: gnome-power-manager tries to decrease the brightness level by 30%. It computes the current level, and it is 100%, it then decreases the brightness to 70%. Since the actual levels are only 7 and truncates this value to level 4 (which correspontos to 66.66%, the first valid level smaller than 70%).

Now I plug my system back. It computes the level and it is now 66.66%, it then increase it to 66.66 + 30 = 96.66%. However this value does not correspond to a discrete, it then truncates the value to the closest level which is now 5 and not 6 anymore. (Note that 5 corresponds to 83.33%, which is much smaller than 96.66%, however gpm always truncate when looking for the correct discreate level).

Now I unplug the system, which is in level 83.33%. It decreases the level to 83.33 - 30 = 53.33%. The new discrete level is now 3 (and not 4 as before in the un-plugged state).

The cycle goes on, loosing one level at a time.

The problem is the truncation, or more precisely the weird idea of increasing or decreaseing the current level by the amount 100 - brightness_battery (in floating point). This kind of floating point computation, when translated to a very small number of discrete levels will always result in weird behavior.

I am proposing a patch that use gpm brightness parameters as absolute targets. When you plug the cord it will take you LCD level to brightness_ac (or leave it alone if it was alerady there or above). When you unplug it will take the level to brightness_battery (or leave it alone if it was already there or below). It also works with the auto-dim feature. Note that my patch uses brightness_battery as a target value. Hence if you want your brightness level to be around 30% of the total level when unplugged set it to 30 (instead of the current 70, which I find odd. I can easily cahnge this).

Please test the patch and say what you think.

If you are too lazy to apply the patch and compile, and if you trust me, you can download a compiled package at

http://www.ime.usp.br/~pjssilva/gnome-power-manager_2.22.1-1ubuntu4_i386.deb

Revision history for this message
Paulo J. S. Silva (pjssilva) wrote :

Sorry... I attached the wrong file to the message above.

Revision history for this message
BandD (swords-into-plowshares) wrote :

I tried to download the package, but I got an error when I tried to open it with Gdebi saying that the package may be corrupted or not being allowed to open the file. It's not a permissions problem (I even tried gksu gdebi-gtk).

I'd be happy to test out the script, the logic of it seems to make sense. But I'm not sure about how to apply the patch. Can you give some instructions on how to do so?

Revision history for this message
Paulo J. S. Silva (pjssilva) wrote :

Sorry, the file was corrupted when I uploaded it to my website. It is fixed now.

If you want to compile it your self you can try the following on a terminal (you'll need to add the source repositories to your apt-sources list):

1) Create a directory to hold gpm source
2) sudo apt-get build-dep gnome-power-manager
3) sudo apt-get source gnome-power-manager
4) sudo apt-get install dpkg-dev fakeroot
5) Download and copy the patch to the directory ./gnome-power-manager-2.22.1/debian/patches
6) Move to the directory gnome-power-manager-2.22-1
7) sudo dpkg-buildpackage -b (and wait the compilation to finish)
8) cd ..
9) Install the deb file

Revision history for this message
BandD (swords-into-plowshares) wrote :

The patch doesn't seem to work on my system, sadly. I get no response when unplugging and plugging in the power cord; the screen brightness doesn't change at all. The screen will dim when idle, but will not restore ANY brightness once the mouse is moved or a key is pressed. I can manually restore brightness, but gpm doesn't react to automatically restore brightness in any way.

If you need any logs or other information, let me know. I'd be happy to help out in whatever way I can. Your idea seems to be going to right direction.

Revision history for this message
Paulo J. S. Silva (pjssilva) wrote :

Thanks for your feedback BandD.

I found a bug in my patch that would prevent it to work if you set some of the brightness parameters to 0 or 100. For example if you had set brightness_ac to 100 (which is a quite reasonable value) it would not work.

I have fixed the bug and I am attaching a new version of the patch. I have also uploaded a new version of the compiled deb to the same location described in my previous messages.

Please try this one and tell me if works. If it doesn't work, I would kindly ask you to send me the current values for brightness_ac, brightness_battery, and idle_brightness, together with some logging output from gnome-power-manager.

To get a log of gnome-power-manager activity, kill the old instace with "killall gnome-power-manger" and call a new one redirecting the output to a log file. Something like this:

gnome-power-manager --verbose --no-daemon 2> /tmo/gpm-log

Revision history for this message
BandD (swords-into-plowshares) wrote :

Ok. The new patch works perfectly for me when setting the idle/active brightness! Nice work there!

I'm still having problems with the battery/ac though. But it I don't know that it is a problem with YOUR patch--perhaps gpm in general or ACPI. I had this problem with the Ubuntu's version of gpm in Hardy (though not in Gutsy). The problem is that when I unplug the power supply the brightness doesn't change, i.e. it doesn't dim at all. The icon in the system tray changes, though when I put my mouse over it is says:

Computer is running on AC power.
Laptop battery 1 hour 35 minutes remaining (78%)

When the power supply is plugged in it says:

Computer is running on AC power.
Laptop batter charging (78%)

So, although it says that it is on AC power in both cases, the second line tells you which is which, when on battery it give the estimated time remaining. When on AC it says the battery is charging. So it's just the first line that gets confused.

This problem is probably not exactly related to this particular bug. But I wanted to give you the full account of what I'm experiencing on my machine. The bottom line is that your patch seems to fix this particular bug. When my screen dims brightness is restored to 100% again. Before this was not the case. So good work! I've also attached a log file that details the dimming/un-dimming cycles and several AC/Battery switches in case you are curious.

Revision history for this message
BandD (swords-into-plowshares) wrote :

Paulo,

I may have found another 'bug'. I've noticed that when when the screensaver (for me blank screen) is activated using your patched version of gpm and deactivate the screensaver (through mouse movement or keystroke), my screen brightness is stuck at the 'dimmed' screen brightness and I have to manually adjust the screen brightness back to 100% with the brightness applet. After that dim on and off works fine. It is just when resuming from the screensaver.

Also, sometimes when resuming from suspend I get the same behavior, but not always.

Revision history for this message
Paulo J. S. Silva (pjssilva) wrote : Re: [Bug 215484] Re: g-p-m does not honor its configuration for LCD brightness levels after multiple unplug-replug from AC

Hi BandD,

The problem after the screen saver resume does not happen to me. Can you
send me a log file that shows this happening?

Paulo
Em Dom, 2008-06-29 às 14:09 +0000, BandD escreveu:
> Paulo,
>
> I may have found another 'bug'. I've noticed that when when the
> screensaver (for me blank screen) is activated using your patched
> version of gpm and deactivate the screensaver (through mouse movement or
> keystroke), my screen brightness is stuck at the 'dimmed' screen
> brightness and I have to manually adjust the screen brightness back to
> 100% with the brightness applet. After that dim on and off works fine.
> It is just when resuming from the screensaver.
>
> Also, sometimes when resuming from suspend I get the same behavior, but
> not always.
>
--
Paulo José da Silva e Silva
Professor Associado, Dep. de Ciência da Computação
(Associate Professor, Computer Science Dept.)
Universidade de São Paulo - Brazil

e-mail: <email address hidden> Web: http://www.ime.usp.br/~pjssilva

Teoria é o que não entendemos o (Theory is something we don't)
suficiente para chamar de prática. (understand well enough to call
practice)

Revision history for this message
BandD (swords-into-plowshares) wrote : Re: [Bug 215484] Re: g-p-m does not honor its configuration for LCD brightness levels after multiple unplug-replug from AC

Paulo,

I'm sorry. It happened only one day--though consistently that day--and I
have not been able to reproduce this bug since. Everything seems to be
working fine.

Thanks!

BandD

On Tue, Jul 1, 2008 at 3:51 AM, Paulo J. S. Silva <email address hidden>
wrote:

> Hi BandD,
>
> The problem after the screen saver resume does not happen to me. Can you
> send me a log file that shows this happening?
>
> Paulo
> Em Dom, 2008-06-29 às 14:09 +0000, BandD escreveu:
> > Paulo,
> >
> > I may have found another 'bug'. I've noticed that when when the
> > screensaver (for me blank screen) is activated using your patched
> > version of gpm and deactivate the screensaver (through mouse movement or
> > keystroke), my screen brightness is stuck at the 'dimmed' screen
> > brightness and I have to manually adjust the screen brightness back to
> > 100% with the brightness applet. After that dim on and off works fine.
> > It is just when resuming from the screensaver.
> >
> > Also, sometimes when resuming from suspend I get the same behavior, but
> > not always.
> >
> --
> Paulo José da Silva e Silva
> Professor Associado, Dep. de Ciência da Computação
> (Associate Professor, Computer Science Dept.)
> Universidade de São Paulo - Brazil
>
> e-mail: <email address hidden> Web: http://www.ime.usp.br/~pjssilva<http://www.ime.usp.br/%7Epjssilva>
>
> Teoria é o que não entendemos o (Theory is something we don't)
> suficiente para chamar de prática. (understand well enough to call
> practice)
>
> --
> g-p-m does not honor its configuration for LCD brightness levels after
> multiple unplug-replug from AC
> https://bugs.launchpad.net/bugs/215484
> You received this bug notification because you are a direct subscriber
> of the bug.
>

Revision history for this message
Percy Leonhardt (p3y) wrote :

The fix from Paulo also works for me but one thing is still wrong: running on AC power, brightness is 100%, then shutting down the laptop and unplugging power, after restarting the brightness stays at 100%, GPM does detect that I am running on battery and is also dimming the display but it does not reduce the brightness to the battery level on startup.

Revision history for this message
Paulo J. S. Silva (pjssilva) wrote : Re: [Bug 215484] Re: g-p-m does not honor its configuration for LCD brightness levels after multiple unplug-replug from AC

Em Dom, 2008-07-13 às 19:50 +0000, Percy Leonhardt escreveu:
> The fix from Paulo also works for me but one thing is still wrong:
> running on AC power, brightness is 100%, then shutting down the laptop
> and unplugging power, after restarting the brightness stays at 100%, GPM
> does detect that I am running on battery and is also dimming the display
> but it does not reduce the brightness to the battery level on startup.
>

Dear Percy,

Maybe the this is another error, not directly related to my patch as I
kept the same behavior of the original gpm in this case. Does the same
problem exists when you use the original gpm? Or is it only present
after using the patched version?

Paulo
--
Paulo José da Silva e Silva
Professor Associado, Dep. de Ciência da Computação
(Associate Professor of the Computer Science Dept.)
Universidade de São Paulo - Brazil

e-mail: <email address hidden> Web: http://www.ime.usp.br/~pjssilva

Teoria é o que não entendemos o (Theory is something we don't)
suficiente para chamar de prática. (understand well enough to call
practice)

Revision history for this message
Percy Leonhardt (p3y) wrote : Re: [Bug 215484] Re: g-p-m does not honor its configuration for LCD brightness levels after multiple unplug-replug from AC

Hi Paulo,

it also happens with the original GPM package. I have the impression
that even GPM from the Hardy RCs did work better... but that just as a
side note.

Revision history for this message
Øyvind Stegard (oyvindstegard) wrote :

I'm the "lucky" owner of a Lenovo Thinkpad Z61m, and when I use the "Dim display when idle" feature, my screen will gradually get darker and darker for every time it kicks in. After a while I must manually increase the brightness again, to get it back to the level it should be at. Ubuntu Hardy 32bit.

Revision history for this message
Jisakiel (jisakiel) wrote :

+1 to that last comment, on an XPS m1330 with intel GMA965 and LED display. Tried resetting the configuration to defaults with no success.

Matt Zimmerman (mdz)
Changed in gnome-power-manager:
importance: Undecided → Medium
status: Confirmed → Triaged
Revision history for this message
BandD (swords-into-plowshares) wrote :

I noticed sometime last week that gpm was not correctly setting the original brightness again after resuming from idle. After looking into it I realized that a new version of gpm had shipped with a round of updates. So I went back to Paulo Silva's patched version and everything is back in order.

Why was Paulo's patch not included in this new updated gpm version?

Revision history for this message
Paulo J. S. Silva (pjssilva) wrote :

BandD,

I am running Ubuntu 8.10 now and the included gpm seems to have the right behavior for me. I don't know if they are using my patch or found another solution for the same problem (I have not looked at the code). Are you still using 8.04? If that is the case, maybe you could try to apply my patch the gpm source and compile your own package. With some luck it may still apply cleanly.

Unfortunately I don't have access to a machine running 8.04 to compile the package right now.

Oh, and just to emphasize. The bug seems closed in 8.10.

Revision history for this message
Scott Howard (showard314) wrote :

This bug report is being closed due to your last comment regarding this being fixed with an update. For future reference you can manage the status of your own bugs by clicking on the current status in the yellow line and then choosing a new status in the revealed drop down box. You can learn more about bug statuses at https://wiki.ubuntu.com/Bugs/Status . Thank you again for taking the time to report this bug and helping to make Ubuntu better. Please submit any future bugs you may find.

Changed in gnome-power-manager (Ubuntu):
status: Triaged → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.