Tweaking Ubuntu for the Lenovo Flexpad

by levien on wo 11 juni 2014 // Posted in misc // under

I don't like to get new equipment if I have old equipment that still works fine. My Asus A2500S laptop is now more than 10 years old, and although it has received a few small repairs and a memory upgrade over the years, it still works fine. Its Pentium 4 Mobile processor may be a power hog, but it's not slow. Its main bottleneck is memory. The full Ubuntu is getting a bit too heavy for the old guy, but Xubuntu still runs like a charm. On the other hand, at over 5 kg (including power-supply) the thing is HEAVY. And two-thirds of the litium-ion-cells in the battery crystallised when I accidentally got the laptop overheated in my bag two years ago, which reduced battery life to about 20 minutes. So, as I increasingly need to work when traveling or on location, I finally decided to get a new laptop.

After some searching around, I settled for a Lenovo IdeaPad Flex 14. The version with an Intel i3-4010U, a 500 Gb harddisk (rather than SSD) and 8 Gb memory was priced at a very reasonable 600 euro. Furthermore, the 14" touchscreen is just big enough to be workable, but the device is small and thin enough to easily fit in my backpack. With some tweaking, you can easily make the battery last for 4 hours of work, and that's with wireless networking enabled.

Given that these newfangled Windows 8 devices use UEFI-booting, I expected a long and painful procedure to get Ubuntu installed. However, after enabling "legacy booting" in the BIOS, installing Ubuntu 14.04 from a bootable USB-pendrive was surprisingly smooth. Moreover, most of the hardware "just worked" out-of-the-box. Video, network, USB, HDMI, sound, touchscreen, camera and cardreader all work just fine, without any customisation (although the default power-settings are not optimal). The only issues I had were with Bluetooth and with the touchpad.

Bluetooth in itself worked fine, but apparently the Bluetooth hardware on the motherboard is slow in initialising. This in turn, causes the entire USB3-stack in the current Linux-kernel to be seemingly randomly disabled after booting, or when resuming from sleep-mode. In other words, sometimes USB-devices (including Bluetooth, the touchscreen and any USB-drives you may have attached) work, sometimes they don't. I don't really use Bluetooth, so I simply disabled it in the BIOS, and after that all USB-devices work without problems. But that's obviously not ideal.

The second issue is that the ALPS GlidePoint touchpad used in the Lenovo Flex 14 and 15 uses the new ALPS v7 protocol, which is not yet supported in the current Linux kernel (3.13.0). A patch has been submitted, but is still under review. Until the driver has been included in the kernel, you can simply install this DKMS-kernel-module to get support for full touchpad-features: https://github.com/he1per/psmouse-dkms-alpsv7

Unfortunately, the default settings of the touchpad are not great. I got lots of spurious click-events when moving the mouse-cursor, especially when using two-finger scrolling. This was highly annoying, so I tweaked the Xorg touchpad-settings until I got something that worked from me.

You can use synclient to list and change the settings on the fly (useful for testing), and man synaptics to get a description of the available settings. To make the settings permanent, add them to an Xorg configuration fragment, e.g. in the /etc/X11/xorg.conf.d directory. For instance, do "gksu gedit /etc/X11/xorg.conf.d 51-touchpad-tweaks.conf &" and insert the following:

    Section "InputClass"
    Identifier "touchpad tweaks"
    MatchIsTouchpad "on"
    MatchDevicePath "/dev/input/event*"

    # I used these settings to greatly reduce spurious clicks, but you may prefer
    # to use a slightly less narrow range of values for FingerLow/High
    # and a somewhat higher value for MaxTapTime (the default is 180 ms).

    Option "FingerLow" "50"
    Option "FingerHigh" "55"
    Option "MaxTapTime" "90"
    Option "TapAndDragGesture" "false"

    # I prefer edge-scrolling to two-finger scrolling

    Option "VertEdgeScroll" "true"
    Option "HorizEdgeScroll" "true"
    Option "VertScrollDelta" "50"
    Option "HorizScrollDelta" "50"
    Option "CornerCoasting" "true"

    # This disables synaptics driver pointer acceleration

    Option "MinSpeed" "1"
    Option "MaxSpeed" "1"

    # Tweak the X-server pointer acceleration

    Option "AccelerationProfile" "2"
    Option "AdaptiveDeceleration" "10"
    Option "ConstantDeceleration" "2"EndSection

You'll also need to disable the Gnome mouse-settings plugin, to stop it from interfering in your settings:

    gsettings set org.gnome.settings-daemon.plugins.mouse active false

Or you can try the alternative method described here: http://askubuntu.com/questions/248290/enable-both-edge-scrolling-and-two...

Finally, I extended the battery-time by installing laptop-mode-tools and tweaking the power-saving features of the Linux kernel a bit (as suggested by powertop). I added the following lines to /etc/rc.local (use "gksu gedit" to edit):

# NMI watchdog should be turned off
echo '0' > '/proc/sys/kernel/nmi_watchdog';
# VM writeback timeout
echo '1500' > '/proc/sys/vm/dirty_writeback_centisecs';
# Enable SATA link power Management for host0
echo 'min_power' > '/sys/class/scsi_host/host0/link_power_management_policy'; 
# Enable SATA link power Managmenet for host1
echo 'min_power' > '/sys/class/scsi_host/host1/link_power_management_policy';
# Enable SATA link power Managmenet for host2
echo 'min_power' > '/sys/class/scsi_host/host2/link_power_management_policy';
# Runtime PM for PCI Device Intel Corporation Haswell-ULT Integrated Graphics Controller
echo 'auto' > '/sys/bus/pci/devices/0000:00:02.0/power/control';
# Runtime PM for PCI Device Intel Corporation Lynx Point-LP SMBus Controller
echo 'auto' > '/sys/bus/pci/devices/0000:00:1f.3/power/control';

More agressive power-saving settings are available (check "powertop --html"), but some seemed to give me warnings in dmesg, so I disabled them. I also added several options to the GRUB_CMDLINE_LINUX_DEFAULT line in /etc/default/grub, namely:

pcie_aspm i915.i915_enable_rc6=1 i915.lvds_downclock=1

However, I did not test how much difference this makes on my laptop. Check out this article for more information on these settings: http://www.phoronix.com/scan.php?page=article&item=intel_i915_power