Saturday, August 24, 2013

Solution to the Twin Devils on Ubuntu Laptops : Heating up and Battery drain

Two major problems I have experienced with Ubuntu on a laptops are heating up and battery drainage. Most of the modern day devices have the capability to save power. The drivers installed on the Ubuntu has the capability to do that also. But they are underutilized. This results in the dual problems of heavy battery drain and heating up. These two problems are interrelated and they can be solve together by doing some manual configurations. The following methods were successfully tested in three hp laptops ( The laptops used processors: AMD A10 with ATI dual graphics, i5 with Intel and ATI dual graphics and Dual Core without graphics card).

1) The first and most important solution to the problem is TLP. (Thanks to my friend who told me about this.) TLP is an advanced power management tool for Linux. It is a pure command line tool with
automated background tasks and does not contain a GUI. Before installing TLP you should remove any scripts you have already added for power saving (e.g.: in /etc/rc.local) and purge the laptop-mode-tools if installed ("sudo apt-get purge laptop-mode-tools").

TLP can be installed on most laptops by running the following commands:

Once TLP is installed we can go with the default settings. But additional tweaking can be done by modifying the TLP settings. (How to tweak the TLP settings discussed below is adopted from askubuntu.com with some minor modifications). The main config file of TLP is at /etc/default/tlp

2) CPU frequency scaling enables the operating system to scale the CPU
frequency up or down in order to save power. CPU frequencies can be
scaled automatically depending on the system load, in response to ACPI
events, or manually by userspace programs. CPU frequency scaling is implemented in Linux kernel, the infrastructure is called cpufreq. Since kernel 3.4 the necessary modules are loaded automatically and the recommended ondemand governer is enabled by default. But you can take control of your cpu frequency and can run on low frequency when you dont need much computational power. This can be done by installing indicator-cpufreq. This indicator will allow you to take control of cpu frequency.

There are 4 default governers available in the program : Conservative, Ondemand, Powersave and Performance. In addition it will show various frequencies to which the processor can be adjusted manually.

This is done by TLP also but you can have a better control using from the GUI by adding this indicator.

3) Using VA-API hardware acceleration on Intel/AMD cards can save power as well as it will give you better rendering of HD videos. This will reduce the power consumption and heat generation on processor while playing videos. This can running the following commands for
Intel:

or for AMD

Mplayer, smplayer or vlc can be used with VA-API. The default mplayer doesnt support it but can be installed by using following commands:

The smplayer with VAAPI can be installed using:

The settings for smplayer can be changed by going to Option tab > Preferences, on the Video tab > General Video > Output driver set the video output driver to "vaapi" as shown here.

VLC media player can be installed using the following commands and can be configured to use VAAPI in Tools > Preferences > Input & Codecs > Enable Use GPU Accelerated decoding and in Videos Enable Accelarated video Overlay Output

These tweakings can reduce the heating problem to a great extent and improve the battery life very much.