Bug 31920

Summary: Brightness control is erratic (/sys/class/backlight/nv_backlight/max_brightness is wrong)
Product: xorg Reporter: Rohan Dhruva <rohandhruva>
Component: Driver/nouveauAssignee: Nouveau Project <nouveau>
Status: RESOLVED FIXED QA Contact: Xorg Project Team <xorg-team>
Severity: normal    
Priority: medium    
Version: git   
Hardware: Other   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments:
Description Flags
dmesg
none
xorg.log
none
lspci
none
Latest dmesg
none
Latest xorg.log none

Description Rohan Dhruva 2010-11-25 10:06:34 UTC
I have a Sony Vaio CW2 laptop, with an Nvidia GeForce 310M card. I am using the nouveau driver from git (via the xorg-edgers ubuntu repository). I have to say it works really well - I even get desktop effects in KDE with Gallium. 

However, there is one problem with screen brightness. The max_brightness value for the backlight interface (/sys/class/backlight/nv_backlight/max_brightness) is set to 1025. When I use KDE power-devil (or any brightness control tool), it reduces the brightness by tiny fractions, which still keeps the screen at full brightness. The brightness actually varies only between 0 and 127 (128-1025 are full brightness), and then too only if I change it in increments of 10 or 20. I think ideally the max_brightness value should be 7 (or 10?) and it should vary in steps of 1.
Comment 1 Rohan Dhruva 2010-11-25 10:08:13 UTC
Created attachment 40571 [details]
dmesg
Comment 2 Rohan Dhruva 2010-11-25 10:08:44 UTC
Created attachment 40572 [details]
xorg.log
Comment 3 Rohan Dhruva 2010-11-25 10:09:16 UTC
Created attachment 40573 [details]
lspci
Comment 4 Rohan Dhruva 2011-01-17 18:25:44 UTC
For a while, I've been using the nvidiabl drive for brightness control. I noticed that it correctly detects the max and min values for my laptop and video card. I was wondering if the nouveau code could somehow benefit from the work done by the nvidiabl author. The code is present here - https://github.com/guillaumezin/nvidiabl

The corresponding thread is here -- http://www.nvnews.net/vbulletin/showthread.php?t=143025 and I think some relevant updates/changes for my laptop model (VPCCW2) are here - http://www.nvnews.net/vbulletin/showthread.php?t=143025&page=8

From all the feedback on the forum, it appears that nvidiabl works fine for everyone. I am not a developer, but if someone could guide me, I could probably help in figuring out how to use nvidiabl code in nouveau. Thanks!
Comment 5 Rohan Dhruva 2011-04-24 01:22:02 UTC
Is there a way to prevent nouveau from creating the /sys/class/backlight/nv_backlight interface? If not, could it be added as a kernel parameter? 

I find that brightness control works much better with the nvidiabl drivers, and I'd prefer to use those with nouveau if possible.
Comment 6 Marcin Slusarz 2011-04-24 01:33:26 UTC
It would be better to integrate nvidiabl into nouveau.
Comment 7 Rohan Dhruva 2011-04-24 01:35:05 UTC
Agreed. Is there some way this could be kickstarted?
Comment 8 Rohan Dhruva 2011-04-24 01:41:18 UTC
I have filed a new issue on the nvidiabl tracker -- https://github.com/guillaumezin/nvidiabl/issues/8
Comment 9 Rohan Dhruva 2011-09-23 23:37:43 UTC
Hello.. Has there been any update on this? Thanks!
Comment 10 Ben Skeggs 2011-09-23 23:50:21 UTC
Try the nouveau kernel git tree, there's been some updates there semi-recently to this area.
Comment 11 Rohan Dhruva 2011-09-25 22:19:47 UTC
I tried both the latest nouveau kernel git tree, and latest X.org packages from git (via the xorg-edgers ubuntu repository). None of them fix this bug.
Comment 12 Ben Skeggs 2011-09-26 04:57:33 UTC
What value does the various nv_backlight files have now?
Comment 13 Rohan Dhruva 2011-09-26 09:24:30 UTC
If anything, it has become less granular now. Here are some of the outputs:

rohan@ubuntu:/sys/class/backlight/nv_backlight$ cat max_brightness 
1025
rohan@ubuntu:/sys/class/backlight/nv_backlight$ cat actual_brightness 
615
rohan@ubuntu:/sys/class/backlight/nv_backlight$ cat brightness 
615
rohan@ubuntu:/sys/class/backlight/nv_backlight$ cat bl_power 
0
rohan@ubuntu:/sys/class/backlight/nv_backlight$ cat brightness 
103
rohan@ubuntu:/sys/class/backlight/nv_backlight$ 

IIRC, the max_brightness is still same as before (1025). However, the actual "max" looks to be something around 615.
Comment 14 Emil Velikov 2011-09-26 11:57:26 UTC
Rohan

Can you please make sure that you are running nouveau kernel git tree [1] as the official kernel does _not_ yet have those changes

If you are interested what those changes are, here is the list [2]


Thanks

[1] http://cgit.freedesktop.org/nouveau/linux-2.6/
[2] http://cgit.freedesktop.org/nouveau/linux-2.6/log/drivers/gpu/drm/nouveau/nouveau_backlight.c
Comment 15 Rohan Dhruva 2011-09-26 11:59:55 UTC
Emil: Thank you for the links! I'm indeed running the latest DRM code. I followed the instructions here -- http://nouveau.freedesktop.org/wiki/InstallDRM. I cloned the repo without history, and did an out-of-tree build.
Comment 16 Emil Velikov 2011-09-26 12:21:16 UTC
Rohan

If you are using the latest kernel code, nouveau will report "max_brightness==100"

See commit drm/nv50/backlight: express brightness level in percent - bc0df418

Cheers
Emil
Comment 17 Rohan Dhruva 2011-09-26 12:29:25 UTC
I just did a git pull, make clean, and recompiled the modules. My modules.dep file also shows that the extra/ directory is being used for nouveau modules. Is there anything else I must be doing? I'm quite sure that the stock ubuntu modules are being overriden.

I'm also attaching my dmesg and xorg.log to be sure :)
Comment 18 Rohan Dhruva 2011-09-26 12:30:13 UTC
Created attachment 51641 [details]
Latest dmesg
Comment 19 Rohan Dhruva 2011-09-26 12:30:46 UTC
Created attachment 51642 [details]
Latest xorg.log
Comment 20 Ben Skeggs 2011-09-26 15:34:52 UTC
(In reply to comment #17)
> I just did a git pull, make clean, and recompiled the modules. My modules.dep
> file also shows that the extra/ directory is being used for nouveau modules. Is
> there anything else I must be doing? I'm quite sure that the stock ubuntu
> modules are being overriden.
> 
> I'm also attaching my dmesg and xorg.log to be sure :)

I'm afraid somehow you're still getting the old driver loaded.  The code in nouveau git *cannot* report max_brightness of 1025 anymore, as evidenced by this section of the patches linked above:

-       props.max_brightness = 1025;
+       props.max_brightness = 100;
Comment 21 Rohan Dhruva 2011-09-26 15:47:25 UTC
Is there any way I can debug this issue? Maybe modify some other file I can modify? Delete the older modules? Thank you for your patience. 

Btw, when will this code merge into mainstream? I was wondering if we'll see it in next release of major distros.
Comment 22 Ben Skeggs 2011-09-26 16:01:12 UTC
(In reply to comment #21)
> Is there any way I can debug this issue? Maybe modify some other file I can
> modify? Delete the older modules? Thank you for your patience. 

I suggest perhaps deleting any directory in /lib/modules that contains nouveau.ko/drm.ko and friends, then reinstalling them from the nouveau git tree you built.


> 
> Btw, when will this code merge into mainstream? I was wondering if we'll see it
> in next release of major distros.

The patches are queued for kernel 3.2.
Comment 23 Lucas Stach 2011-09-27 01:09:13 UTC
Don't know if Ubuntu uses this, but Fedora stuffs the nouveau driver into the initrd. If Ubuntu does a similar thing you have to rebuild your initrd after installing the new modules to get your newly built nouveau loaded.
Comment 24 Alex Mayorga Adame 2012-03-31 22:55:16 UTC
Did this make it into kernel 3.2? What can be done for the brightness controls to work properly?

I reported https://bugs.launchpad.net/nouveau/+bug/551668 a while ago on Ubuntu's bug tracker I believe is this bug or a related one and it is still causing problems on the following configuration:

alex-mayorga@VPCCW1FFXL:~$ uname -a
Linux VPCCW1FFXL 3.2.0-21-generic #34-Ubuntu SMP Fri Mar 30 04:25:35 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
alex-mayorga@VPCCW1FFXL:~$ lspci -nn | grep VGA
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GT216 [GeForce GT 230M] [10de:0a2a] (rev a2)
alex-mayorga@VPCCW1FFXL:~$ apt-cache show xserver-xorg-video-nouveau
Package: xserver-xorg-video-nouveau
Priority: optional
Section: x11
Installed-Size: 344
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian X Strike Force <debian-x@lists.debian.org>
Architecture: amd64
Version: 1:0.0.16+git20111201+b5534a1-1build2
Provides: xorg-driver-video
Depends: libc6 (>= 2.4), libdrm-nouveau1a (>= 2.4.23), libudev0 (>= 147), xorg-video-abi-11, xserver-xorg-core (>= 2:1.10.99.901)
Recommends: libgl1-mesa-dri (>= 7.11.1)
Filename: pool/main/x/xserver-xorg-video-nouveau/xserver-xorg-video-nouveau_0.0.16+git20111201+b5534a1-1build2_amd64.deb
Size: 109400
MD5sum: 5ab8e5861a11a57d783fa9862d88900f
SHA1: 7abb48438df08eed97dd4676bc111bdbaf714376
SHA256: 886d7e2f968819373d81a932388ede20995d9bd1d3d8f2091100f988a314a780
Description-en: X.Org X server -- Nouveau display driver
 This driver for the X.Org X server (see xserver-xorg for a further description)
 provides support for NVIDIA Riva, TNT, GeForce, and Quadro cards.
 .
 This package provides 2D support including EXA acceleration, Xv and
 RandR.  3D functionality is provided by the libgl1-mesa-dri package.
 .
 This package is built from the FreeDesktop.org xf86-video-nouveau driver.
Homepage: http://nouveau.freedesktop.org/wiki/
Description-md5: b084a16945b86c1eda89ad33dbb4530d
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 5y
Task: ubuntu-desktop, ubuntu-usb, kubuntu-desktop, kubuntu-active-desktop, kubuntu-active, edubuntu-desktop, edubuntu-usb, xubuntu-desktop, mythbuntu-frontend, mythbuntu-desktop, mythbuntu-backend-slave, mythbuntu-backend-master, lubuntu-core, ubuntustudio-desktop
Comment 25 Rohan Dhruva 2012-03-31 23:00:06 UTC
This has been working for me since kernel 3.1, in Fedora 16. I also tried kernel 3.2 in Ubuntu 12.04, and it has been working fine out of the box.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.