NVIDIA/Optimus

Laptops with NVIDIA graphics cards using NVIDIA Optimus can be configured to render scenes on the discrete NVIDIA GPU (Graphics Processing Unit) card using x11-drivers/nvidia-drivers and copy the rendered scenes to the Intel GPU using XRandR.

It is recommended to have an alternative boot method available such as bootable CD-ROM or DVD.

Kernel configuration
Consider setting:

xorg.conf configuration
http://us.download.nvidia.com/XFree86/Linux-x86_64/331.38/README/optimus.html http://us.download.nvidia.com/XFree86/Linux-x86_64/331.38/README/randr14.html

Using monitor EDID saved to a file
It is probably best to first try a simple configuration first like described in the NVIDIA driver manual:

http://us.download.nvidia.com/XFree86/Linux-x86_64/331.38/README/randr14.html

Some laptops may benefit from saving the EDID screen information to a file so it can be passed to the NVIDIA and Intel modesetting drivers. The EDID information can be saved like:

The EDID information is provided to the Intel GPU (Graphics Processing Unit) by specifying its location in the kernel boot parameter:

drm_kms_helper.edid_firmware=edid/1920x1080_clevo_W670SR.bin

If you are using the grub boot loader on Gentoo this can be configured in the file /etc/default/grub:

Note: On Sabayon linux the kernel boot parameters should be specified in the /etc/default/sabayon-grub file instead of /etc/default/grub.

Debugging your NVIDIA Optimus configuration
If your configuration does not work, then an approach to debug it is to carefully read the /var/log/dmesg and /var/log/Xorg.0.log files to look for problems, then to make changes to the kernel configuration, kernel boot parameters, the /etc/X11/xorg.conf file, etc. as necessary, then try it again. It may require many attempts to obtain a working configuration.

To aid in distinguishing between unimportant and important messages in the /var/log/dmesg and /var/log/Xorg.0.log files, examples are provided below for a working configuration with the above example /etc/X11/xorg.conf file on a Clevo W670SR notebook.

Configuration prior to starting X
Per NVIDIA's instructions, the following commands are required before starting X

$ xrandr --setprovideroutputsource modesetting NVIDIA-0 $ xrandr --auto

These commands can be added to your X session startup scripts such as $HOME/.xinitrc before running startx.

Use the command

$ xrandr --listproviders

command to find the appropriate graphics device.

for menu option (a) KDE-4
Add the xrandr commands to the end of the file:

/etc/X11/Sessions/KDE-4

for menu option (b) Your .xsession
Add the xrandr commands to the file:

~/.xsession

qingy directfb
In the directfb configuration file:

/etc/directfbrc

It is necessary to set the busid parameter to the busid of the Intel graphics card reported by:

For example, if lspci says the Inntel graphics card is on busid 00:02.0, then add the following line to /etc/directfbrc:

CDM
Add the xrandr commands to the file:

~/.xinitrc

KDM KDE
Add the xrandr commands to the file:

/usr/share/config/kdm/Xsetup

MDM
For Mint desktop Manager fetch the ebuild and

Add the xrandr commands to the file:

/etc/X11/mdm/Init/Default

XDM
Add the xrandr commands to the file:

/usr/lib/X11/xdm/Xsetup_0

on 32-bit systems or on

/usr/lib64/X11/xdm/Xsetup_0

for 64-bit systems. Alternatively, edit

/etc/X11/xdm/xdm-config

and edit the line

DisplayManager._0.setup:     /usr/lib/X11/xdm/Xsetup_0

to point to another script that adds the xrandr commands.

Other display managers
Any Display Manager that starts using X-Windows then asks the user to log in will result in a black screen unless a way can be found to run the necessary xrandr commands before asking the user to log in.