To make the Fn keys to work, Ubuntu loads the sony-laptop module. When nvidia_bl is also loaded, then lshal shows two backlight devices in /sys/devices/virtual/backlight, which are sony and nvidia_backlight. Fn-F5, Fn-F6 keys, gnome-power-preferences and gnome-brightness applet actually work but they all change /sys/class/backlight/sony/brightness.
As a workaround, I use a slightly modified version of the script at
. Then I added two files into /etc/acpi/events to map Fn-F5 and Fn-F6 keys to change the brightness using that script.