# laptop display brightness control and laptop power savings?

## kokyu

hey all,

last time I installed Gentoo on my netbook, I was able to change display back-light brightness (Acer Laptop with intel GPU).

Now, I'm having a new Laptop, but since then, I cannot change its LCD back-light brightness, which I highly need to save power consumption while traveling.  :Smile: 

I do not know what package I might be missing.

I'm using KDE desktop (and it's power management UI)

Any ideas what I can do?

What package/configuration might I be missing to be able to make use of KDE's (display!) power management features?

Thanks in advance,

Kokyu.

----------

## sebaro

For backlight:

> grep BACKLIGHT /boot/config

For power savings:

> grep ACPI /boot/config

Make sure you have both enabled.

----------

## kokyu

ah. a very interesting point, yes. many thanks so far.

the following is for backlight, and I seem to have already enabled as much as possible within that section.

```
windsor [~] > zgrep BACKLIGHT /proc/config.gz 

CONFIG_FB_BACKLIGHT=y

CONFIG_BACKLIGHT_LCD_SUPPORT=y

CONFIG_BACKLIGHT_CLASS_DEVICE=y

CONFIG_BACKLIGHT_GENERIC=y

# CONFIG_BACKLIGHT_PROGEAR is not set

# CONFIG_BACKLIGHT_APPLE is not set

# CONFIG_BACKLIGHT_SAHARA is not set

CONFIG_BACKLIGHT_ADP8860=y

CONFIG_BACKLIGHT_ADP8870=y

# CONFIG_LEDS_TRIGGER_BACKLIGHT is not set

CONFIG_DRM_NOUVEAU_BACKLIGHT=y
```

```
windsor [~] > zgrep ACPI /proc/config.gz 

CONFIG_X86_64_ACPI_NUMA=y

# Power management and ACPI options

CONFIG_ACPI=y

CONFIG_ACPI_SLEEP=y

CONFIG_ACPI_PROCFS=y

CONFIG_ACPI_PROCFS_POWER=y

# CONFIG_ACPI_EC_DEBUGFS is not set

CONFIG_ACPI_PROC_EVENT=y

CONFIG_ACPI_AC=y

CONFIG_ACPI_BATTERY=y

CONFIG_ACPI_BUTTON=y

CONFIG_ACPI_VIDEO=y

CONFIG_ACPI_FAN=y

CONFIG_ACPI_DOCK=y

CONFIG_ACPI_PROCESSOR=y

CONFIG_ACPI_HOTPLUG_CPU=y

CONFIG_ACPI_PROCESSOR_AGGREGATOR=y

CONFIG_ACPI_THERMAL=y

CONFIG_ACPI_NUMA=y

# CONFIG_ACPI_CUSTOM_DSDT is not set

CONFIG_ACPI_BLACKLIST_YEAR=0

# CONFIG_ACPI_DEBUG is not set

CONFIG_ACPI_PCI_SLOT=y

CONFIG_ACPI_CONTAINER=y

CONFIG_ACPI_SBS=y

CONFIG_ACPI_HED=y

# CONFIG_ACPI_CUSTOM_METHOD is not set

CONFIG_ACPI_APEI=y

CONFIG_ACPI_APEI_GHES=y

# CONFIG_ACPI_APEI_PCIEAER is not set

# CONFIG_ACPI_APEI_MEMORY_FAILURE is not set

CONFIG_ACPI_APEI_EINJ=y

CONFIG_ACPI_APEI_ERST_DEBUG=y

CONFIG_X86_ACPI_CPUFREQ=y

CONFIG_HOTPLUG_PCI_ACPI=y

# CONFIG_HOTPLUG_PCI_ACPI_IBM is not set

CONFIG_PNPACPI=y

CONFIG_ATA_ACPI=y

# CONFIG_PATA_ACPI is not set

# ACPI drivers

# ACPI drivers

# CONFIG_SENSORS_ACPI_POWER is not set

# CONFIG_ACPI_QUICKSTART is not set

# CONFIG_THINKPAD_ACPI is not set

CONFIG_ACPI_WMI=m

# CONFIG_ACPI_ASUS is not set

# CONFIG_ACPI_TOSHIBA is not set

# CONFIG_ACPI_CMPC is not set

```

for acpi the same, but I guess the CONFIG_ACPI_ASUS might be relevant, too, since it's an Asus laptop.

Thanks so far,

kokyu.

----------

## sebaro

I can't help you with the ACPI/power savings part. But for gamma correction and brightness/backlight you can try x11-apps/xgamma and x11-apps/xbacklight.

----------

## chithanh

See if you have controls in /sys/class/backlight . There should be a file named "brightness" in one of the subdirectories, and writing numbers to it should change the brightness.

If no such control exists or it has no effect, then something is wrong with your kernel still.

----------

## kokyu

 *chithanh wrote:*   

> See if you have controls in /sys/class/backlight . There should be a file named "brightness" in one of the subdirectories, and writing numbers to it should change the brightness.
> 
> If no such control exists or it has no effect, then something is wrong with your kernel still.

 

aha. That's it. many thanks.

this is the output: *Quote:*   

> laptop ~ # /bin/ls -lh /sys/class/backlight/
> 
> total 0
> 
> lrwxrwxrwx 1 root root 0 Jan  5 10:13 acpi_video0 -> ../../devices/pci0000:00/0000:00:02.0/backlight/acpi_video0
> ...

 

Writing to intel_backlight/brightness (value between 0..999) works, however, setting the value in acpi_video0/brightness (0..9, default 4) then it is ignored.

I assume that KDE's power management is just trying to set the first instead of the intel_backlight/brightness then and I could consider this a bug in either KDE (using the wrong backlight controller) or the kernel (ignoring my writes to acpi_video0/brightness) then... hmmmm  :Sad: 

Cheers,

Kokyu.

p.s.: edit: yep. tested it. changing the acpi_video0/brightness value by hand reflects the GUI settings in KDE's battery panel.

----------

## B-Man

 *kokyu wrote:*   

>  *chithanh wrote:*   See if you have controls in /sys/class/backlight . There should be a file named "brightness" in one of the subdirectories, and writing numbers to it should change the brightness.
> 
> If no such control exists or it has no effect, then something is wrong with your kernel still. 
> 
> aha. That's it. many thanks.
> ...

 

I have found the same issue on my laptop.  Any luck in fixing this?  I have found a few other bug reports with KDE that support was added but no luck getting it to work yet.

----------

## ultraslinky

Have you tried using xbacklight? I'm in your situation, the ACPI backlight control only works for maximum and minimum brightness and the only way to change the brightness is xbacklight or writing to the file in /sys.

----------

## kokyu

nope, did not try xbacklight, I'd rather like to see KDE being fixing that (power management on hybrid graphics laptops).

I wrote I tiny script to aid my "mobile"-mode  :Smile: 

```

#! /bin/bash

MAX_BRIGHTNESS=$(cat /sys/class/backlight/intel_backlight/max_brightness)

if [[ "$1" == "reset" ]]

then

        CPU_SCALING_GOVENOR=performance

        BRIGHTNESS=$MAX_BRIGHTNESS

        POWER_POLICY=max_performance

else

        CPU_SCALING_GOVENOR=ondemand

        BRIGHTNESS=$[MAX_BRIGHTNESS * 10 / 100]

        POWER_POLICY=min_power

fi

cvar() {

        echo "$1 = $2" && echo $2 > $1

}

cvar /sys/class/backlight/intel_backlight/brightness $BRIGHTNESS

for prefix in /sys/devices/system/cpu/cpu?; do

        cvar $prefix/cpufreq/scaling_governor $CPU_SCALING_GOVENOR

done

for prefix in /sys/class/scsi_host/host?; do

        cvar $prefix/link_power_management_policy $POWER_POLICY

done

```

be aware, in that (personal) script, I access the brightness of my intel_backlight card, as this is, what I only use (had no success with my secondary NVIDIA card on it yet) - you may want to adjust it.

I run this script once I start working mobile (e.g. having no external power cable connected), and run it again with the "reset" parameter passed as soon as I am back stationary (with power cable plugged in)  :Smile: 

hope this script is inspiring  :Smile: 

Kokyu.

----------

## dachschaden

I know that this thread is about two years old, but like I give a fuck ... also non-native english speaker/writer, cut me some slack.

I got the same problem as the OP with XFCE4. The difference is that I am a programer and debugger, and thus I was able to find out some very interesting informations concerning this problem.

First, the directories in /sys/class/backlight named like "acpi_videoX" are activated by the ACPI_VIDEO switch, documented in Documentation/acpi/video_extension.txt.

Well, OK, that isn't true, because the switch isn't mentioned ONCE in the document.

And: I cannot turn it off, for reasons involving quantum mechanics and what <Insert name of the guy who's responsible for the module> had for lunch last friday. 

Is it only me, or are there people who would support my theory that the idiots programming the kernel are autists which expect other to follow their weird logic? THIS is exactly the reason why linux won't launch off on the desktop - even Microsoft isn't that incompetent. I, as a user, do not care how much work you put into your module, if it does not work and trying to fix the problem involves reading kernel documentation someone - and it's NOT me - is doing something terribly wrong (and that coming from someone who uses Gentoo as main OS ...)

OK, but I am programmer, so I am supposed to have lower standards ... I mean, hey, I can read code, so I am destined to do it, right?

By chance I found out that the /sys/class/backlight/-directory gets populated by drivers/acpi/video.c, currently in acpi_video_dev_register_backlight, line 1661. (version 3.15).

Let's ignore the fact that the code is horrifying enough to cause me nightmares if I'd ever sleep, and just insert a "return;" at the beginning of the function, recompile and reboot ...

```

# ls -lah /sys/class/backlight/

insgesamt 0

drwxr-xr-x  2 root root 0 22. Jun 04:58 .

drwxr-xr-x 33 root root 0 22. Jun 04:58 ..

lrwxrwxrwx  1 root root 0 22. Jun 2014  intel_backlight -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/intel_backlight

```

Well, OK. I know have just one backlight object, and setting the brightness file changes my screen brightness as well. Everything's allright.

Except for the little fact that all user space applications which are supposed to give me access to my screen brightness think that there is no access to it.

At this point I would have downloaded the source of xfce4-brightness-plugin, my program which even now shamelessly lies in my face that it cannot access my backlight, but for another reasons including the color of the eye shade of mister programmer's missus as well as the amount of helium present in the sun (not to mention the very important reasons above) the Gentoo developers decided that THIS VERY PACKAGE wouldn't be named after the name of the program it manages, so it's not available for separate emerging, ebuilding and you-know-what. If you expect me to debug stuff, make it easy or die trying.

And THIS is the very reason why I think that we need some sort of coder licence, in contrast to a driver licence. If you can't do it, you get your licence voided. At least one licence would have been revoked this morning just for my problem.

Enough rant. I will just leave this here - I have spent enough of my lifetime debugging this crap. I found a workaround, it's not nice, but at least it works, it makes my kernel smaller, and I can feel smug about people who screw up IT infrastructure.

Whoever wants to annoy all the programmers at the window manager teams to death has enough ammunition for this now. Make'em suffer.  :Wink: 

So long,

dachschaden.

PS: After another session of thinking about the problem I decided to fool all broken user space programs by symlinking to a acpi_video0 directory - but sysfs has no support for this. OK, my bad.

So I just edited the name of the device to register from "intel_backlight" to "acpi_video0" in drivers/gpu/drm/i915/intel_panel.c, intel_backlight_device_register, in line 876.

```

# ls -lah /sys/class/backlight/

insgesamt 0

drwxr-xr-x  2 root root 0 22. Jun 13:37 .

drwxr-xr-x 33 root root 0 22. Jun 13:37 ..

lrwxrwxrwx  1 root root 0 22. Jun 2014  acpi_video0 -> ../../devices/pci0000:00/0000:00:02.0/drm/card0/card0-eDP-1/acpi_video0

```

It worked - that is, the renaming of the device.

But my user space tools still cannot adjust the brightness, and now I am not sure who is in fault for this. On one hand I can set the screen brightness manually, on the other one the directory is now named as I'd suppose they expect it to be.

I am a bit ... well, how do they put it in english ... flabbergasted.

Oh, Xorg recognizes the device just fine:

 *Quote:*   

> 
> 
> Xorg.0.log:[    14.123] (--) intel(0): found backlight control interface /sys/class/backlight/acpi_video0
> 
> 

 

One thing was setting me off, though:

 *Quote:*   

> 
> 
> Jun 22 13:37:37 asgard kernel: [    2.221335] asus_wmi: Backlight controlled by ACPI video driver
> 
> 

 

I am using an ASUS laptop, and the asus_wmi support is compiled into the kernel (for fancy things like, well, illuminated keys on my keyboard - which do not work in Gentoo, but in Kali with the very same kernel, but that's another story).

The point is, this message comes from drivers/platform/x86/asus-wmi.c, asus_wmi_add. But since ACPI is broken on my laptop as well - and noone seems to care, except for the nouveau guys (but they couldn't help me there and referred me to the freedesktop.org guys who just seem to try to sit it dead).

I am giving up here. And for all the others out there with problems concerning the backlight: Either use the interface already described here to set your brightness, or annoy the dudes who programmed the infrastructure to death. I have invested already too much of my lifetime trying to debug shit from people who clearly should never have programmed anything.

----------

## feniksa

Go to kernel:

# cd /usr/src/linux

Device Drivers -> x86 Platform Specific Drivers -> WMI

You should DISSABLE WMI support, for ASUS laptop it doesn't works.

After recompile of kernel and update, backlight control should work.

Thanks for help in this thread

----------

