Laptop + 2 video cards - how to live?

    Recently, manufacturers have a tendency to put on their laptops two video cards - one some kind of simple Intel's to save energy, and the other - fancy for games and video. As far as I know, Lenovo surely does this, and I and my HP TouchSmart tm2-1080er fell under the same trend. If on the preinstalled Windows 7 Home x64 the ability to switch between cards, of course, was available, then Windows 7 Professional x32 did not want to include the second video card. The situation was no better in Ubuntu - both are determined by video cards, but only Intel default is preferred. And the food is eating, of course, both - as a result, the laptop works much less than it should. How will we deal with this?
    So, we have two video cards:
    $ lspci | grep VGA
    00:02.0 VGA compatible controller: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller (rev 07)
    01:00.0 VGA compatible controller: ATI Technologies Inc M93 [Mobility Radeon HD 4500 Series] (rev ff)

    Our task is to either learn to switch between two video cards, or at least turn off the power of the second video card.

    The first way. To Kill a Mockingbird.

    The first way is simple. We will take a ready-made module written for Lenovo notebooks (it is also suitable for our wonderful HP) and make it screw onto our core. To do this, we will use deb packages and the dynamic module screwing system - DKMS.
    I called the module unpretentiously - hp_acpi_kill.

    We take the source code of the module and save it under the name hp_acpi_kill.c
    Now we put the Makefile next .
    This is our required module, written by an unknown enthusiast for OpenSUSE.

    Now we need to write a config for DKMS so as not to rebuild the module for each new version of the kernel. Fortunately, DKMS is very simple and the configuration is short. Downloadand save as dkms.conf. In this file we indicate the name of the compiled module, its version, as well as how to compile and install our module. It would seem that we can stop here - add the module to DKMS, assemble and install it - but we are still users of a convenient distribution kit, and don’t understand what. Therefore, we will wrap our module in a package.
    I will not go into details of the package assembly, since I already wrote a lot about it on the Habr, I will only say that in addition to the usual set of files, we need * .postinst, *. Postrm, * .prerm files - so that our module is registered and compiled in DKMS with install the package, and also cleaned it out during uninstallation. Download the archive with all the necessary files here .

    We collect the package with the debuild or dpkg-buildpackage command to choose from, install and add the name of the hp_acpi_kill module to / etc / modules - now when the system boots up, the discrete graphics card will turn off and power consumption will drop sharply.
    Having looked at the list of devices, we find that our video card is visible to the system, but not detected:
    $ lshw
    product: Illegal Vendor ID
    vendor: Illegal Vendor ID
    physical id: 0
    bus info: pci@0000:01:00.0
    version: ff
    width: 32 bits
    clock: 66MHz
    capabilities: bus_master vga_palette cap_list rom
    configuration: driver=radeon latency=255 maxlatency=255 mingnt=255
    resources: irq:31 memory:c0000000-cfffffff ioport:3000(size=256) memory:e4400000-e440ffff memory:e4420000-e443ffff

    The second way. vga_switcheroo

    The second method will require us a little traffic and a bit of time. The fact is that not so long ago, version 2.6.34 of the kernel was released, which included a new interesting module - vga_switcheroo, which is designed to switch video cards. On Launchpad and you can even find packages with this kernel, but the module is turned off in the default config - probably because they have not yet come up with convenient graphics tools for switching video cards.

    Therefore, to get started, download the source package from the lunchpad (it is designed for Maverick Meerkat, but it will work fine for us too):
    $ wget
    $ wget

    Unpack it:
    $ dpkg-source -x linux_2.6.34-2.9.dsc

    Now let's go to the linux-2.6.34 directory and open the debian.master / config / config.common.ubuntu file with any favorite editor. Find the line "# CONFIG_VGA_SWITCHEROO is not set" and replace it with "CONFIG_VGA_SWITCHEROO = y" (quotation marks are not needed).
    Just in case, open another debian / config / enforce file and add the line “value CONFIG_VGA_SWITCHEROO y” in it - this will help during the assembly to make sure that not a single infection has corrupted the parameter set.
    We compile with the debuild command (it will take a long time to build, because EVERYTHING is assembled when the package is built) and install:
    $ sudo dpkg -i linux-headers-2.6.34-2_2.6.34-2.9_all.deb linux-headers-2.6.34-2-generic_2.6.34-2.9_i386.deb linux-image-2.6.34-2-generic_2.6.34-2.9_i386.deb
    If you have a 64-bit system, instead of i386, the file name will, of course, be amd64.

    How can we switch the graphics card to a new kernel after rebooting? Let's look at the summary of the Soviet information bureau:
    $ cat /sys/kernel/debug/vgaswitcheroo/switch
    1: :Off:0000:01:00.0

    The plus sign shows us the active video card, Pwr mark - that the video card is on, Off - that it is off. What can be changed? There is a wonderful list of commands that can be passed to vga_switcheroo:
    DIS - immediate switch to a discrete graphics card
    IGD - immediate switch to an integrated graphics card
    DDIS - delayed switch to a discrete graphics card
    DIGD - delayed switch to an integrated graphics card
    ON - turn on an unused video card
    OFF - turn off an unused video card

    I must say right away that immediate switching does not give me any immediate effect.
    Therefore, we will command:
    # echo ON > /sys/kernel/debug/vgaswitcheroo/switch # включим дискретную видеокарту
    # echo DDIS > /sys/kernel/debug/vgaswitcheroo/switch # попросим при случае переключить на дискретную видеокарту

    Now we click in the system "end the session", log in again and turn off the integrated video card:
    # echo OFF > /sys/kernel/debug/vgaswitcheroo/switch

    We look at the result:
    $ $ cat /sys/kernel/debug/vgaswitcheroo/switch
    0: :Off:0000:00:02.0

    Now you can play games, watch HD-video and not waste power on the Intel card. And you can switch back and spend even less energy on a full-fledged video card, saving battery. She is long.

    Also popular now: