# The Ubuntu Forum Community > Ubuntu Specialised Support > Apple Hardware Users > [all variants] MacBook(Pro) with Nvidia graphics adapter display backlight fix call for testing

## _mario_

Hi all,

the display backlight on those models with Nvidia graphics adapter is always at its maximum brightness after resuming from suspend, but the chip, and thus the driver, still reports the last recently set value. This updated driver fixes this issue, by re-sending the value upon suspend. Can anyone please confirm that it actually works?

Instructions:
1. Install the attached deb package and reload the module:


```
sudo dpkg -i mbp-nvidia-bl-dkms_0.11_all.deb
sudo rmmod mbp_nvidia_bl
sudo modprobe mbp_nvidia_bl
```

2. MacBookPro 3 and 4 users: Set display brightness to some low value, e.g.:


```
echo 1 | sudo tee /sys/class/backlight/mbp_backlight/brightness
```

, suspend, resume and report whether it works.

3. MacBook 5 and MacBookPro 5 users: This might also work for the new 5th generation models. I don't have these machines and thus cannot test it. Please check out this driver and report whether it works at all.

4. If it didn't work, remove the package:


```
sudo apt-get remove --purge mbp-nvidia-bl-dkms
```

If you want to have a look, the sources are attached as well.

thanks & ciao,
Mario

EDIT: removed attachments. use the mactel PPA instead.

----------


## _mario_

> 2. MacBookPro 3 and 4 users: Set display brightness to some low value, suspend, resume and report whether it works.


well, how surprising, of course it works on my MacBookPro 4.

----------


## kosumi68

Great work, mario!

I am excited about the possibility that this might actually fix the problem with heat and battery life on the new unibody Macbooks.

----------


## hyperboloid

> the display backlight on those models with Nvidia graphics adapter is always at its maximum brightness after resuming from suspend, but the chip, and thus the driver, still reports the last recently set value. This updated driver fixes this issue, by re-sending the value upon suspend. Can anyone please confirm that it actually works?
> 
> Instructions:
> 1. Install the attached deb package and reload the module:
> 
> 
> ```
> sudo dpkg -i mbp-nvidia-bl-dkms_0.11_all.deb
> sudo rmmod mbp_nvidia_bl
> ...


It is working _almost_ OK on my MBP 4,1 running Ubuntu 8.10 release. Upon reboot/suspend the previous display brightness setting is remembered. 

_One small problem:_ When the brightness is very low, one encounters a black screen upon resume, and at that point (before password verification) the brightness controls are disabled, so one must enter the password blindly and then use the controls to manually up the display brightness. 

This seems like a rounding issue with a floating point variable, although I have not tried to look at the code. Anyway, perhaps a minimum threshold should be something non-zero so that the display will never come back completely black, which is disconcerting. 

By the way, the suggested code in step 2 

```
sudo echo 1 > /sys/class/backlight/mbp_backlight/brightness
```

 does not work for me - it gives me back "permission denied" even though I did not forget the "sudo" prefix. Very strange. Anyway, I set the brightness using the manual control F1-F2.

Good work, Mario. Can you similarly figure out a way to make it remember the KEYBOARD backlight settings after suspend/reboot?

----------


## ercoppa

For me seems not to work on MacBook 5,1 2.0Ghz. The applet on GNOME not change the brightness.


```
ercoppa@ercoppa-laptop:~$ lsmod | grep nvidia
mbp_nvidia_bl          11140  0 
nvidia               6900560  28 
agpgart                42184  1 nvidia
i2c_core               31892  1 nvidia
ercoppa@ercoppa-laptop:~$ modinfo mbp_nvidia_bl 
filename:       /lib/modules/2.6.27-7-generic/updates/dkms/mbp_nvidia_bl.ko
alias:          svnAppleInc.:pnMacBookPro5,1
alias:          svnAppleInc.:pnMacBook5,1
alias:          svnAppleInc.:pnMacBookPro4,1
alias:          svnAppleInc.:pnMacBookPro3,2
alias:          svnAppleInc.:pnMacBookPro3,1
license:        GPL
description:    Nvidia-based Macbook Pro Backlight Driver
author:         Matthew Garrett <mjg@redhat.com>
srcversion:     DBA60E7089F1D0F6F752D48
depends:        
vermagic:       2.6.27-7-generic SMP mod_unload modversions 586 

ercoppa@ercoppa-laptop:~$ sudo echo 1 > /sys/class/backlight/mbp_backlight/brightness 
bash: /sys/class/backlight/mbp_backlight/brightness: Permission denied

root@ercoppa-laptop:/home/ercoppa# echo 1 > /sys/class/backlight/mbp_backlight/brightness 

root@ercoppa-laptop:/home/ercoppa# echo 1 > /sys/class/backlight/mbp_backlight/actual_brightness 
bash: /sys/class/backlight/mbp_backlight/actual_brightness: Permission denied

ercoppa@ercoppa-laptop:~$ sudo echo 1 > /sys/class/backlight/mbp_backlight/brightness 
bash: /sys/class/backlight/mbp_backlight/brightness: Permission denied

ercoppa@ercoppa-laptop:~$ cat /sys/class/backlight/mbp_backlight/brightness 
1
ercoppa@ercoppa-laptop:~$ cat /sys/class/backlight/mbp_backlight/actual_brightness 
15
```

Anyway thanks for the work  :Smile: 

How can I help you?

----------


## cyberdork33

> By the way, the suggested code in step 2 
> 
> ```
> sudo echo 1 > /sys/class/backlight/mbp_backlight/brightness
> ```
> 
>  does not work for me - it gives me back "permission denied" even though I did not forget the "sudo" prefix. Very strange


It doesn't work because it is really two different commands... You don't need sudo for the echo command, (you normal user can do that), but you need sudo for '>' command because you are trying to pipe to a protected file.

Try it like this:


```
echo 1 |sudo tee /sys/class/backlight/mbp_backlight/brightness
```

----------


## kosumi68

> ```
> sudo echo 1 > /sys/class/backlight/mbp_backlight/brightness
> ```
> 
>  does not work for me - it gives me back "permission denied" even though I did not forget the "sudo" prefix. Very strange.


It should read


```
echo 1 | sudo tee -a /sys/class/backlight/mbp_backlight/brightness
```

file pipes do not work with sudo (it is a different command, executed as the normal user)

EDIT: oops - I obviously forgot to refresh my tab  :Smile:

----------


## kosumi68

> For me seems not to work on MacBook 5,1 2.0Ghz. The applet on GNOME not change the brightness.


Does the thank you to cyberdork's post mean it works for you to change the screen brightness on the MacBook5,1?

----------


## ercoppa

> Does the thank you to cyberdork's post mean it works for you to change the screen brightness on the MacBook5,1?


The command works (only for /sys/class/backlight/mbp_backlight/brightness) but the brightness doesn't change.

P.s. excuse me for my bad english  :Sad:

----------


## cyberdork33

> It should read
> 
> 
> ```
> echo 1 | sudo tee -a /sys/class/backlight/mbp_backlight/brightness
> ```
> 
> file pipes do not work with sudo (it is a different command, executed as the normal user)
> 
> EDIT: oops - I obviously forgot to refresh my tab


Just a small off-topic question... Doesn't the -a switch mean append? Does it make a difference if you append or replace for a sys file like that?

----------


## _mario_

> Blacklisting the module and then loading it manually, the Kernel boots (last stable vanilla Kernel) but the console where one runs modprobe hangs (modprobe never exits)
> 
> The module loads and creates the backlight/mbp_backlight/ filesystem, but the process hangs trying to either read "actual_brightness" or write to "brightness"


what's in your /var/log/kern.log? did the module crash?




> Edit: using Mario's nvidia_bl module works changing the brightness through nvidia_backlight/brightness and within X!!! I'm just surprised I didn't try this before trying mbp_nvidia_bl!.


in general, nvidia-bl is the better module, but doesn't support the MacBook Pro 5. do you have a MacBook Pro 5?

ciao,
Mario

----------


## ercoppa

undoIT, the script for the keyboard simply (Mario helps me) is:


```
#! /bin/sh

case "$1" in
    start)
        echo `cat /root/.keybacklight` > /sys/class/leds/smc::kbd_backlight/brightness
        ;;
    restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
    stop)
        cat /sys/class/leds/smc::kbd_backlight/brightness > /root/.keybacklight
        ;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac
```

Test it (I don't have PRO).

Greets, ercoppa.

----------


## undoIT

> undoIT, the script for the keyboard simply (Mario helps me) is:
> 
> 
> ```
> #! /bin/sh
> 
> case "$1" in
>     start)
>         echo `cat /root/.keybacklight` > /sys/class/leds/smc::kbd_backlight/brightness
> ...


This works, but after logging in, once the desktop is loaded, Gnome resets the brightness to 100%. So there is somewhere else that the brightness is being set. I edited the settings in gconf-editor so that keyboard brightness is 0 for both AC and battery, but still Gnome insists on 100%.

----------


## _mario_

you can also change:



> ```
> echo `cat /root/.keybacklight` > /sys/class/leds/smc::kbd_backlight/brightness
> ```


to:


```
cat /root/.keybacklight > /sys/class/leds/smc::kbd_backlight/brightness
```




> This works, but after logging in, once the desktop is loaded, Gnome resets the brightness to 100%. So there is somewhere else that the brightness is being set. I edited the settings in gconf-editor so that keyboard brightness is 0 for both AC and battery, but still Gnome insists on 100%.


this is gnome-power-manager, that for some reason i don't know, always sets the keyboard brightness to maximum when starting.

ciao,
Mario

----------


## undoIT

> this is gnome-power-manager, that for some reason i don't know, always sets the keyboard brightness to maximum when starting.


Bad gnome... Obey my commands!

 :Wink:

----------


## mulbric3

Unfortunately this is* not working* on my Macbook Pro 3,1.
*The archive is not found!*

This is driving me nuts. I'm new too Linux Mint 11. Some problems like Blueooth and Sound took me forever to fix.

I'm not sure if this helps. I've got the following packeges installed:

nvidia-common
nvidia-current
nvidia-settings

Thank you for any help.

----------


## mulbric3

Help!

----------


## mbradlcu

I don't see any option with nvidia-settings, but apparently the brightness can be set via CL:


```
sudo echo "100" > /sys/class/leds/smc\:\:kbd_backlight/brightness
```

I'm using ubuntu 10.04 lts

----------

