Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In order to control my backlight, I need to do the following:

sudo setpci -s 00:02.1 F4.B=x

This could be read as:

For the PCI device with the ID 00:02.1, set the register F4 (byte only) to x.

To figure out a value I want for x, I'd like to read its current value (in a script I'm writing). How do I do this?

Early work:

This seems to be the domain of lspci. I tried

sudo lspci -x -s 00:02.1

but this doesn't give enough range (doesn't reach register/address F4). I can do it with the -xxx command line, however. This gives me a dump at which I can see the byte at F4, which I verified I can manipulate with the setpci command. However, the manual says:

  -xxx   Show hexadecimal dump of the whole PCI configuration space. It is  available  only  to  root  as  several  PCI
         devices  crash when you try to read some parts of the config space (this behavior probably doesn't violate the
         PCI standard, but it's at least very stupid). However, such devices are rare, so you needn't worry much.

So I'd rather not put that in a program that runs automatically as root. Any way to just read the value for register F4? A getpci program? A setpci flag? Some special lspci flag I missed?

(Environment is Ubuntu Netbook Remix 9.04 (karmic) (32-bit) on a Samsung N140 netbook)

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

You want the program setpci. It looks like this format would do what you want:

setpci -s 00:02.1 F4.B

See man setpci: the only difference with your version is you're trying to set the register, so you name it and assign a value ("F4.B=x"). Here, just name it; don't assign a value.

From the manpage:

Operations

To query value of a configuration register, just name it (either by typing its name or by typing register address with optional .B, .W or .L suffix specifying register width as byte, word or longword).

To set a register, write reg=values where reg is the same as you would use to query the register and values is a comma-separated list of values you want to write starting with the given address. Each value to be written can be specified either as a hexadecimal number or as a bits:mask pair which causes the bits corresponding to binary ones in the mask to be changed to values of the corresponding bits in the bits

share|improve this answer
    
How did I not think of this. Perfect, thanks. –  Paul Biggar Dec 26 '09 at 0:56
    
i would've looked for a getpci first too... –  quack quixote Dec 26 '09 at 1:11
add comment

Take into account that this will not work if your display uses the new intel_backlight interface (until this date only the gnome power manager can manage it).

Please read this: http://askubuntu.com/questions/57236/unable-to-change-brightness-in-a-lenovo-laptop/81389#81389 and the links listed Especially my post (under the name Álvaro)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.