Lenovo Thinkpad W540

This article describes installation and configuration instructions for the Lenovo Thinkpad W540. Although several different configurations for the model exist, these instructions should work for all of them. Note that the model documented does not contain a WAN card, and other sources should be explored for configuration of the hardware.

Hardware

 * Intel® Core™ i7-4600M Processor (4M Cache, up to 3.60 GHz)
 * NVIDIA® Quadro® K1100M with Optimus
 * 15.6" FHD (1920 x 1080), anti-glare, 300 nits, 500:1 contrast ratio
 * 16GB PC3-12800 1600MHz DDR3L, non-parity, dual-channel capable DDRM
 * Integrated 720p HD Camera
 * 9-cell Li-Ion battery - 57++ (99.9Wh)
 * Fingerprint Reader
 * 4-in-1 card reader (MMC, SD, SDHC, SDXC), supports UHS-II SD card
 * 1 x Ethernet (RJ45)

Optional WAN Cards:
 * Ericsson N5321 Mobile Broadband HSPA+
 * Sierra Wireless EM7355 (mutually exclusive with M.2 SSD)

lspci
Use the following lspci output to determine what kernel drivers are used for the hardware. This is especially useful when configuring wifi (``iwlwifi`` is used). Note that even though a Core i7 is used in the configuration, ``lspci`` displays it as a Xeon. It is a 4th generation processor none the less.

lsusb
The following output can be used to determine the USB drivers. It also shows the vendor of the fingerprint reader, which is not configured in this guide.

Firmware
All of the required firmware, including the wifi driver should be available in the package.

Kernel
This does not include specific settings to, for example, the init system that you are using, or the graphics drivers.

Note at the time this article was written, the kernel version used was 4.12.5

Note: Bluetooth was not tested on the system. The kernel parameters enabled for bluetooth are based on previous thinkpad articles.

Video Card Setup with Nvidia Binary Drivers
The laptop has a dual GPU setup operating on Nvidia Optimus. The integrated intel card is what is attached to the laptop screen, and the discrete Quadro card is what interfaces with the outside HDMI and DisplayPort. It is possible to run the laptop without the discrete graphics card for better power usage, however doing so will sacrifice the ability to output to HDMI or Display Port. To do so, simply compile only for the intel driver, and X-server should pick everything up by default without any extra configuration.

The better option is to use the discrete card. Note that it's recommended to use the binary nvidia driver in place of the open source nouveau driver, as the binary driver offers the best performance, and features Prime Synchronization, which eliminates screen tearing (a prominent problem on the laptop as it uses hybrid graphics). The caveat is that the discrete card has no ability to turn off on the binary driver, thus offering worse battery performance compared to the nouveau driver.

To configure your system to use the binary driver, add to your VIDEO_CARDS field in make.conf:

Update the system, which should automatically install the nvidia driver package.

Your X.org server configuration should look like this. This will enable PRIME on the device, allowing the machine to use both its discrete card for rendering, and intel card for displaying to laptop screen.

Prime Synchronization
To eliminate any screen tearing, PRIME Synchronization will need to be enabled. To do this, some nvidia kernel modules have to be loaded in at startup. Add the following entries to the nvidia.conf file in the modprobe.d folder:

You will also have to add the following lines to your or display manager start script:

After a restart,you can verify that prime is working and functioning by running xrandr, which should produce the following outputː

You can also verify that Prime Synchronization is turned on by looking at the Prime Synchronization field under the eDP-1-1 field:

More information
 * NVidia/nvidia-drivers - For more information on installing the nvidia drivers
 * NVIDIA/Optimus - For more information on what optimus is

External resources

 * https://wiki.archlinux.org/index.php/PRIME
 * https://wiki.archlinux.org/index.php/NVIDIA_Optimus
 * https://wiki.archlinux.org/index.php/NVIDIA