LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-16-2011, 02:04 PM   #1
kopatops
Member
 
Registered: Mar 2010
Distribution: Arch Linux
Posts: 45
Blog Entries: 1

Rep: Reputation: 16
Backlight level is incremented every time laptop lid is closed


Hi,

I recently did a full system upgrade (which makes this hard to point to a specific package). Also I opened the laptop for dusting.

Now, every time I close the laptop lid, when I open it again, the backlight level is lower than before I closed it. The value is incremented by a certain value, according to an unknown rule.

I start out at full brightness:

Code:
[stupijar][~]$ setpci -s 00:02.0 F4.B
ff
I close the lid and open it again. Now the screen has been dimmed, but:

Code:
[stupijar][~]$ setpci -s 00:02.0 F4.B
ff
Setpci thus reports an unchanged value. I set the permissions so any user can change the value:

Code:
[stupijar][~]$ ls -l "/sys/bus/pci/devices/0000:00:02.0/config" 
-rw-r--rw- 1 root root 256 Feb 16 20:39 /sys/bus/pci/devices/0000:00:02.0/config
When I do

Code:
setpci -s 00:02.0 F4.B=FF
The backlight level is back at maximum (for real) and setpci still reports a level of ff.

Furthermore, the dimming can be repeated by successive lid close/open operations, until it is completely dark.

Could this be a hardware problem? Should I roll back Xorg, or my Intel drivers? Anyone recognizes the symptoms?

Thanks!

EDIT: Since I dusted the interiors of the computer, the power LED is constantly on, even when it is shut down. This could support the hardware fault theory. Something has changed in there...

Last edited by kopatops; 02-16-2011 at 02:07 PM.
 
Old 02-17-2011, 08:38 AM   #2
easuter
Member
 
Registered: Dec 2005
Location: Portugal
Distribution: Slackware64 13.0, Slackware64 13.1
Posts: 538

Rep: Reputation: 62
Quote:
Originally Posted by kopatops View Post
Hi,

I recently did a full system upgrade (which makes this hard to point to a specific package). Also I opened the laptop for dusting.

Now, every time I close the laptop lid, when I open it again, the backlight level is lower than before I closed it. The value is incremented by a certain value, according to an unknown rule.

I start out at full brightness:

Code:
[stupijar][~]$ setpci -s 00:02.0 F4.B
ff
I close the lid and open it again. Now the screen has been dimmed, but:

Code:
[stupijar][~]$ setpci -s 00:02.0 F4.B
ff
Setpci thus reports an unchanged value. I set the permissions so any user can change the value:

Code:
[stupijar][~]$ ls -l "/sys/bus/pci/devices/0000:00:02.0/config" 
-rw-r--rw- 1 root root 256 Feb 16 20:39 /sys/bus/pci/devices/0000:00:02.0/config
When I do

Code:
setpci -s 00:02.0 F4.B=FF
The backlight level is back at maximum (for real) and setpci still reports a level of ff.

Furthermore, the dimming can be repeated by successive lid close/open operations, until it is completely dark.

Could this be a hardware problem? Should I roll back Xorg, or my Intel drivers? Anyone recognizes the symptoms?

Thanks!

EDIT: Since I dusted the interiors of the computer, the power LED is constantly on, even when it is shut down. This could support the hardware fault theory. Something has changed in there...
I didn't have this exact same problem, but a similar one on an old laptop I had. Every time I opened the lid, the backlight would be completely dimmed out, so as a workaround I put the command to restore the backlight brightness as an acpid event, activated whenever the laptop lid opened (see /etc/acpi/acpi_handler.sh)

Sorry, I know this isn't an ideal solution. The Arch wiki will probably have more specific info for you.
 
Old 02-17-2011, 03:39 PM   #3
kopatops
Member
 
Registered: Mar 2010
Distribution: Arch Linux
Posts: 45

Original Poster
Blog Entries: 1

Rep: Reputation: 16
Quote:
Originally Posted by easuter View Post
I didn't have this exact same problem, but a similar one on an old laptop I had. Every time I opened the lid, the backlight would be completely dimmed out, so as a workaround I put the command to restore the backlight brightness as an acpid event, activated whenever the laptop lid opened (see /etc/acpi/acpi_handler.sh)

Sorry, I know this isn't an ideal solution. The Arch wiki will probably have more specific info for you.
Thanks anyway easuter, this works fine. Specifically, I did the following:
File: /etc/acpi/handler.sh

Code:
#!/bin/sh
# Default acpi script that takes an entry for all actions

# NOTE: This is a 2.6-centric script.  If you use 2.4.x, you'll have to
#       modify it to not use /sys

minspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
maxspeed=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
setspeed="/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed"

set $*
[.........................................]
        case "$2" in
            BAT0)
                case "$4" in
                    00000000)   #echo "offline" >/dev/tty5
                    ;;
                    00000001)   #echo "online"  >/dev/tty5
                    ;;
                esac
                ;;
            CPU0)	
                ;;
            *)  logger "ACPI action undefined: $2" ;;
        esac
        ;;
    button/lid)
        #echo "LID switched!">/dev/tty5
        grep open /proc/acpi/button/lid/LID/state && ~/bin/blight max
        ;;
    *)
        logger "ACPI group/action undefined: $1 / $2"
        ;;
esac
, where ~/bin/blight max sets the brightness to maximum. In reality I used the absolute path to the blight script, I think handler.sh is executed as root (?).

Not marking as SOLVED.

Last edited by kopatops; 02-17-2011 at 03:44 PM.
 
Old 03-03-2011, 07:33 PM   #4
cb474
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Rep: Reputation: 0
kopatops,

I am also on a fully upgraded Arch (x86_64) system and am having exactly the problem you describe (on a Thinkpad T61). It started a couple weeks ago, so probably at the same time as you.

I don't have the /etc/acpi/handler.sh script though and really know nothing about scripts. If I want to use your workaround and create the script and all I want is the fix for the lid brightness issue, what part of the script do I need? (I don't want to add any extra acpi events that I don't already have).

Alternatively, I see on my system that there is already a /etc/acpi/actions/lm_lid.sh script. Can something be added to that to achieve the same workaround?

Thanks for any help.

cb474
 
Old 03-05-2011, 02:51 AM   #5
kopatops
Member
 
Registered: Mar 2010
Distribution: Arch Linux
Posts: 45

Original Poster
Blog Entries: 1

Rep: Reputation: 16
cb474,

(Do you have acpid installed?)

On my setup I have the file "/etc/acpi/events/anything" with the following content:

Code:
# Pass all events to our one handler script
event=.*
action=/etc/acpi/handler.sh %e
That is, whenever *any* acpi event is detected, handler.sh is called to execute some command (based on what event was detected). In handler.sh every event has a corresponding action. I basically set the action corresponding to the button/lid event (lid was opened) to
Code:
setpci -s 00:02.0 F4.B=ff
,where 00:02.0 is my display controller ID (check with lspci | grep VGA) and ff is the maximum brightness value. This might return a "permission denied" error on your system. You need to change the permissions for the config file mentioned in that message, so brightness can be changed by your user ID.

anything and handler.sh shoud be installed by the package acpid. This is described on the Arch Wiki here together with instructions on how to add your own custom event handlers (but acpid is required for the workaround):

https://wiki.archlinux.org/index.php..._configuration

Could you post the contents of that lm_lid.sh file?
___________________

I found it most easy to just use those files preinstalled by acpid, but I guess you can create your own event handler just for button/lid.

Now, if you want to do something based on the event that the lid state was changed, the first thing to do is identify that event. Assuming you have acpid installed, do

sudo acpi_listen

and close/open the laptop lid. I get
Code:
$ acpi_listen
button/lid LID 00000080 00000001
button/lid LID 00000080 00000002
, so I might create a file /etc/acpi/events/lidchange with the contents
Code:
event=button lid.*
action=/etc/acpi/actions/maxbright.sh "%e"
and a file /etc/acpi/actions/maxbright.sh with the contents

Code:
#!/bin/sh
grep open /proc/acpi/button/lid/LID/state && setpci -s 00:02.0 F4.B=ff  # If lid was opened, set brightness to max
Also make this last file (script) executable with
Code:
sudo chmod +x /etc/acpi/actions/maxbright.sh

Last edited by kopatops; 03-05-2011 at 03:22 AM.
 
Old 03-05-2011, 04:04 PM   #6
cb474
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Rep: Reputation: 0
Thanks kopatops! I'll get to work on this and see if I can get it to work.
 
Old 03-05-2011, 09:35 PM   #7
cb474
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Rep: Reputation: 0
So you were right that I did not have acpid installed. I didn't realize at first that acpid is a daemon related to acpi and not synonymous with the acpi module. Once I installed acpid, the handler.sh file showed up.

As I said, however, even before I installed acpid there was already a lm_lid.sh file on my system, found at: /etc/acpi/actions/lm_lid.sh.

lm_lid.sh had the following default contents in it:
Code:
#! /bin/sh

test -f /usr/sbin/laptop_mode || exit 0

# lid button pressed/released event handler

/usr/sbin/laptop_mode auto
I don't know if this is kosher or not, but all I did was after the last line of lm_lid.sh add:
Code:
setpci -s 00:02.0 F4.B=ff
So my whole lm_lid.sh now reads:
Code:
#! /bin/sh

test -f /usr/sbin/laptop_mode || exit 0

# lid button pressed/released event handler

/usr/sbin/laptop_mode auto
setpci -s 00:02.0 F4.B=ff
That seems to have solved the problem.

One question I have is that now that the handler.sh file is operating with acpid on my system, is that going to effect other settings I have on my machine, for the power button, ac adapter, etc (all things that the script looks like it effects)? If I don't need handler.sh, should I just comment it out in /etc/acpi/events/anything?

That aside, thanks super much again for this post and your help. I never would have figured this out on my own.
 
Old 03-06-2011, 03:28 AM   #8
kopatops
Member
 
Registered: Mar 2010
Distribution: Arch Linux
Posts: 45

Original Poster
Blog Entries: 1

Rep: Reputation: 16
Glad it worked!

The default handler.sh doesn't seem to do anything with the events detected, it only logs them happening (and even this is commented out in my file). That is, you may get an entry in /var/log/messages.log every time e.g. power button is being pressed. If you want any other command to be executed based on power button being pressed (e.g. shutdown/standby/hibernate), you need to insert that command in the proper row in handler.sh.

So no, handler.sh shouldn't interfere with your own settings in its default format, and you could let it be or comment it out of /etc/acpi/events/anything as you see fit.
 
Old 03-06-2011, 03:45 AM   #9
kopatops
Member
 
Registered: Mar 2010
Distribution: Arch Linux
Posts: 45

Original Poster
Blog Entries: 1

Rep: Reputation: 16
http://www.gentoo-wiki.info/HOWTO_Au...f_your_monitor

This document indeed describes /etc/acpi/actions/lm_lid.sh as an acpid script (executed by acpi daemon). However inserting the setpci line as you did:

Quote:
Originally Posted by cb474 View Post
I don't know if this is kosher or not, but all I did was after the last line of lm_lid.sh add:
Code:
setpci -s 00:02.0 F4.B=ff
So my whole lm_lid.sh now reads:
Code:
#! /bin/sh

test -f /usr/sbin/laptop_mode || exit 0

# lid button pressed/released event handler

/usr/sbin/laptop_mode auto
setpci -s 00:02.0 F4.B=ff
would probably set the backlight to max when lid is either closed or opened. If this is not the case you can just ignore this comment. Otherwise, check for state open by replacing
Code:
setpci -s 00:02.0 F4.B=ff
with
Code:
grep open /proc/acpi/button/lid/LID/state && setpci -s 00:02.0 F4.B=ff
and setpci will run only if LID state was changed and LID state is now open.

Good luck

Last edited by kopatops; 03-06-2011 at 03:46 AM.
 
Old 03-07-2011, 06:37 PM   #10
cb474
LQ Newbie
 
Registered: Mar 2011
Posts: 4

Rep: Reputation: 0
My backlight doesn't seem to be coming on when I shut the lid. It looks like it's off. But I changed the code in the script to "grep..." as you suggest, just in case. Thanks.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
KDE 4.5.1 crashes when laptop lid is closed and desktop effects is on yuchankit Slackware 2 10-14-2010 10:46 AM
Screen not useable after laptop lid closed yuchankit Slackware 9 09-29-2010 04:36 AM
Ubuntu Server Wakeonlan Not Working When Laptop Lid Closed D11011101 Linux - Laptop and Netbook 1 03-27-2009 02:41 PM
Standby on laptop when lid closed LDJ Linux - Newbie 5 01-16-2007 06:08 PM
laptop lid won't shut off when closed houler Slackware 32 08-27-2005 11:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration