AMD graphics cards, Linux basic power management

Introduction

If you buy a new laptop with Intel processors and AMD graphics cards, you by default run into this long running dual, hybrid graphics problem under Linux. This post is targeted towards new Linux users, who haven’t dealt with such kinds of problems before.

Problem

I have summarized queries, that is often asked by new Linux users, who use these hardware.

  • My laptop gets extremely hot while running X distribution
  • Laptop fan is constantly running, how do I calm or stop it
  • My laptop is very hot under Linux
  • Battery life under Linux is very low
  • Brightness resets everytime I restart the computer

Inspection

First, we have to determine, if you run the AMD-Intel hybrid graphics cards. Open up a terminal (Ctrl + Alt + T) and type following command

lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
01:00.0 VGA compatible controller: Advanced Micro Devices [AMD] nee ATI Seymour [Radeon HD 6400M/7400M Series] (rev ff)

Here, first line is the command I typed, and the rest is its output. As you can see, it shows two graphics cards. The one, that is causing the computer to heat up is the second (AMD).

Temporary Solution

Run following commands in a terminal

sudo su
echo OFF > /sys/kernel/debug/vgaswitcheroo/switch

If you haven't let your computer heat up for quite some time, above command should shutdown the AMD card. Note though, this command only works, if you haven't installed catalyst driver. I suggest, you use this command every time you install a new Linux based operating system, even if you plan to install the catalyst driver later.

You can inspect the situation using following commands.

sudo su
cat /sys/kernel/debug/vgaswitcheroo/switch

This file is pretty explanatory (ON and OFF).

Permanent Solution

There are basically two ways to solve these problems

a. Installing propitiatory catalyst driver

I have already written two articles on this. However, you should know it is not as safe as running the open source drivers, that is already installed on your computer.

i. How to setup AMD/Intel Hybrid graphics cards in Linux (Ubuntu

ii. Fix catalyst driver in Ubuntu 13.04

Many people run distributions other than Ubuntu. I am sure with these information, it should not be that hard to find articles targeted specifically for your distro.

b. Making above command active on boot

You need to add text we used earlier, inside /etc/rc.local file. Open up the file and add vgaswitcheroo line.

sudo gedit /etc/rc.local
#!/bin/sh -e
# Some comments
echo OFF > /sys/kernel/debug/vgaswitcheroo/switch
exit 0

As you can see, we did not install anything. You just need to shutdown the AMD card. Intel cards are quite capable for everyday tasks. However, if you do serious gaming, going with the first option (catalyst driver) is the only option. Open source AMD drivers are getting serious attention these days, in terms of development. I am hopeful power management situation improves very soon.

Power Management

Even with Intel cards, you might still not get the desired battery life from your laptop. Here are couple of solutions to the battery problem.

a. Install laptop-mode-tools

There are other options too, specially tlp, but I still find laptop-mode-tools quite good. Use following command to install laptop-mode-tools

sudo apt-get install laptop-mode-tools

b. Kernel (Optional, advanced)

Note: You can escape this section, because it is not that significant, except for long battery hours and enabling brightness (save current settings or for tools like laptop-mode-tools). Also, if you play games, enabling deep sleep (rc6) can cause graphics card to slowdown and or freeze while playing games or using graphics intensive programs. Therefore, you may want to escape this section (use xbacklight instead for brightness as discussed below) or be vigilant about these issues.

I like to keep certain parameters active in the kernel. In /etc/default/grub make GRUB_CMDLINE_LINUX variable look like this.

GRUB_CMDLINE_LINUX="drm.vblankoffdelay=1 i915.i915_enable_rc6=7 i915.lvds_downclock=1 i915.i915_enable_fbc=1"

If you have a dell laptop, you can also play with dell_laptop.backlight option too as

GRUB_CMDLINE_LINUX="drm.vblankoffdelay=1 i915.i915_enable_rc6=7 i915.lvds_downclock=1 i915.i915_enable_fbc=1 acpi_backlight=vendor dell_laptop.backlight=0"

To activate these options for next boot onwards, run following command

sudo update-grub

If your laptop constantly hangs, you can change i915.i915_enable_rc6=7 to i915.i915_enable_rc6=1  to lower the sleep level, but as I said above, you need to be aware of these changes, when your laptop goes haywire. See Kernel Command Line Parameters to get a sense of how you can change rc6 values.

Brightness

Above commands should help fix the laptop brightness issue (for dell laptops). If it does not, you have to rely upon yet another command to solve this problem.

However, let us first find out which file is working to set brightness in your computer. Go inside /sys/class/backlight directory. Open File Manager and click Computer drive and browse to that directory. There should be a directory say acpi_video0 or intel_backlight. Open the file brightness, and see its value. If you have more that one directory, you have to experiment with each one using different values. However, before setting any value, open up its brightness file, to get a sense of the range of brightness values it supports. E.g In some cases it is in thousands, and in some cases the range is just within 1 and 15. You can set the value using following commands.

sudo su
echo 2294 > /sys/class/backlight/intel_backlight/brightness

Once you have found a value that works, put it inside /etc/rc.local.

sudo gedit /etc/rc.local
echo 2294 > /sys/class/backlight/intel_backlight/brightness
echo OFF > /sys/kernel/debug/vgaswitcheroo/switch
exit 0

Note: There is a bug in Ubuntu, that might prevent /etc/rc.local from executing the brightness script. In that case, you might have to consider following options.

If you want different levels of brightness, based on laptop on charge or on battery, you might want to edit /etc/laptop-mode/conf.d/lcd-brightness.conf instead, with following values.

CONTROL_BRIGHTNESS=1
BATT_BRIGHTNESS_COMMAND="echo 700"
LM_AC_BRIGHTNESS_COMMAND="echo 1954"
NOLM_AC_BRIGHTNESS_COMMAND="echo 1954"
BRIGHTNESS_OUTPUT="/sys/class/backlight/intel_backlight/brightness"

Using the command line, check these values before setting them on this file. If you restart laptop-mode service, it should work immediately (or restart the computer for convenience).

sudo service laptop-mode restart

If this too does not set the brightness value, you can install a program called xbacklight. After installing try to set values, to see if it works.

sudo apt-get install xbacklight
xbacklight -set 30

It should set the brightness to 30 percentage of the maximum. Since this program works without root, you could do all kinds of magic with it, e.g writing a cron job to constantly write the brightness value to a file, and write another script that sets the brightness using xbacklight using the value from that file. However, if you are generally going to stick with a fixed brightness value, it is easier to set it as a startup script. You could copy one of the files inside /home/username/.config/autostart and change the Exec line to set the command or go the easy route by opening up Startup Applications and adding an entry.

Name: Xblack or whatever
Command: xbacklight -set 30

Conclusion

I haven't covered everything, but these settings should be enough for you to get a decent battery life and fix AMD graphics issues on AMD-Intel hybrid graphics setup on a laptop.

I hope, it helps.

Cheers !!

References

About these ads

Leave a comment

Filed under Uncategorized

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s