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.

Installation
At the time this article was written version 346.22 of was the most recent (unstable) version of the driver in the Portage tree, therefore examples that reference a specific version will presume 346.22. When a newer version of the driver is released, or if an older version is selected, simply substitute 346.22 for the desired version.

Installing NVIDIA drivers is easy, simply run the following:

Configuration
Configuring a system to use NVIDIA's propritary driver is not easy as the installation. There are several configuration files that will need to be modified in order for a system to work properly.

Kernel Configuration
Since NVIDIA Optimus will be using the integrated Intel graphics, the following kernel options will need to be enabled:

Xorg.conf Configuration
The best way to set the system's xorg.conf correctly would be to read the documentation NVIDIA has provided. The documentation can be found in a couple of locations. To save time, consider reading only the pages on Optimus and XRandR, as they are vital to correct configuration. If the driver has already been emerged (done in the installation step above), the documentation can be found locally at.

Example: Use the less command to read the local documentation:

It is also possible to read the documentation at NVIDIA's website by following these (external) links:

http://us.download.nvidia.com/XFree86/Linux-x86_64/346.22/README/optimus.html

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

Using Specific Monitor via EDID
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/346.22/README/randr14.html

Saving the Monitor's EDID
Some laptops/notebooks 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 using the read-edid utility.

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.

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

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

This is to say any Display Manager that starts X-Windows then asks the user to log in will result in a black screen unless the above XRandR commands are run before asking the user to log in.

Use the XRandR command to find the appropriate graphics device:

$ xrandr --listproviders

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 as reported by the lspci command:

For example, if lspci says the Intel graphics card is on BusID 00:02.0, then add the following line to {{Path}/etc/directfbrc}}

CDM
Add the xrandr commands to the file:

~/.xinitrc

KDM
Add the xrandr commands to the file:

/usr/share/config/kdm/Xsetup

MDM
For Mint desktop Manager fetch the ebuild and install

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

If the system is a 32-bit system, modify:

/usr/lib64/X11/xdm/Xsetup_0

If a using a 64-bit system, then modify:

/etc/X11/xdm/xdm-config

Edit the follwing line to point to another script that will run the xrandr commands:

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