Monday 28 December 2009

Solution to switch off nvidia card in Linux Asus UL30Vt, UL50V, UL80V

If you are using Linux on an Asus UL30Vt, or Asus UL50Vt or Asus UL80Vt, keep reading...

One of the Linux users has found a solution to switch off the nvidia card in the UL30Vt models,
which by the looks of the DSDT tables, will also work for the UL50Vt and UL80Vt models with nvidia card.

For Ubuntu Karmic, download and install this package:

http://launchpadlibrarian.net/38458054/nvidia-g210m-acpi-source_0.1.0-1%7Eppa-karmic_all.deb

Then once installed, run the following command on a terminal:

sudo modprobe nvidia_g210m_acpi


Explanation:

This module uses the ACPI P0P1.VGA._OFF method, which is the same for all 3 models.

The code file, "asus_nvidia.c" is derived from "lenovo_acpi.c" by Sylvain Joyeux.

Here is the original post and another one that adds hibernation support:
http://forum.notebookreview.com/showpost.php?p=5663702&postcount=1239
http://forum.notebookreview.com/showpost.php?p=5664880&postcount=1244

asus_nvidia.c
========================================================
#include <acpi/acpi.h>
#include <linux/suspend.h>

MODULE_LICENSE("GPL");

static acpi_handle root_handle;

static int kill_nvidia(void)
{
acpi_status status;
// The device handle
acpi_handle handle;
struct acpi_object_list args;
// For the return value
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };

status = acpi_get_handle(root_handle, "\\_SB.PCI0.P0P1.VGA._OFF", &handle);
if (ACPI_FAILURE(status))
{
printk("%s: cannot get ACPI handle: %s\n", __func__, acpi_format_exception(status));
return -ENOSYS;
}

args.count = 0;
args.pointer = NULL;

status = acpi_evaluate_object(handle, NULL, &args, &buffer);
if (ACPI_FAILURE(status))
{
printk("%s: _OFF method call failed: %s\n", __func__, acpi_format_exception(status));
return -ENOSYS;
}
kfree(buffer.pointer);

printk("%s: disabled the discrete graphics card\n",__func__);
return 0;
}

static int power_event(struct notifier_block *this, unsigned long event,
void *ptr)
{
switch (event) {
case PM_POST_HIBERNATION:
kill_nvidia();
return NOTIFY_DONE;
case PM_POST_SUSPEND:
case PM_HIBERNATION_PREPARE:
case PM_SUSPEND_PREPARE:
default:
return NOTIFY_DONE;
}
}

static struct notifier_block power_notifier = {
.notifier_call = power_event,
};

static int __init asus_nvidia(void)
{
int ret = register_pm_notifier(&power_notifier);
if (ret) return ret;
return kill_nvidia();
}

static void dummy(void)
{
}

module_init(asus_nvidia);
module_exit(dummy);
========================================================

Makefile
========================================================
ifneq ($(KERNELRELEASE),)
obj-m := asus_nvidia.o
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) $(EXTRA_FLAGS) modules

clean:
$(MAKE) -C $(KERNELDIR) M=$(PWD) $(EXTRA_FLAGS) clean

endif
========================================================

To compile it, simply run:

Code:
make
To install it, run as root:
Code:
cp asus_nvidia.ko /lib/modules/`uname -r`/kernel/<br />depmod
To try it out, run as root:
Code:
modprobe asus_nvidia
To load it on each reboot on Ubuntu, run as root:
Code:
echo asus_nvidia >>/etc/modules
That last step will be different on other distros, e.g., on Gentoo you need to append the module name to /etc/modules.autoload.d/kernel-2.6.<br />


43 comments:

  1. How do you know if this works? Is there a way of testing to see if the Nvidia GPU is running or not? Thanks for the help.

    ReplyDelete
  2. @john
    once you've modprobe'd the module, do a:
    lspci | grep -i VGA
    and you should only see one line.
    Also, running your laptop on battery, you can do:
    sudo powertop
    and you should see a lower wattage value after modprobing.

    ReplyDelete
  3. I'm running Arch linux, and I can't get that to work. When I try to 'make' it, it just tells me that there's nothing to be done for default.

    ReplyDelete
  4. Hey, I have spend some time with trying to work nvidia with those proprietary drivers and still had notsucceeded.
    Thus I have just swithced it of fith the upper code.

    ReplyDelete
  5. I couldn't compile it either on my Slackware. I got the same result as Osman did

    ReplyDelete
  6. i have tested this on my UL80VT, and still it gives me NVIdia when i do lspci | grep -i VGA

    root@laptop:/home/willysr/usr/src/dkms_source_tree$ lspci | grep -i VGA
    00:02.0 VGA compatible controller: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller (rev 07)
    01:00.0 VGA compatible controller: nVidia Corporation Device 0a74 (rev ff)

    root@laptop:/home/willysr/usr/src/dkms_source_tree$ modprobe asus_nvidia

    root@laptop:/home/willysr/usr/src/dkms_source_tree$ lspci | grep -i VGA
    00:02.0 VGA compatible controller: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller (rev 07)
    01:00.0 VGA compatible controller: nVidia Corporation Device 0a74 (rev ff)

    ReplyDelete
  7. Ups... it seems the entry has changed from rev a2 into ff. I hope it works :)

    ReplyDelete
  8. Also fails for me on Fedora 12

    ReplyDelete
  9. Hi,

    I also get

    maigre@maigre-laptopUL:~$ sudo modprobe nvidia_g210m_acpi
    maigre@maigre-laptopUL:~$ lspci | grep -i VGA
    00:02.0 VGA compatible controller: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller (rev 07)
    01:00.0 VGA compatible controller: nVidia Corporation Device 0a74 (rev ff)

    It seems to fail with ff revision.. or did i miss something ? any idea ?

    cheers

    ReplyDelete
  10. Hi,

    i change my previous post :
    i reinstalled Ubuntu 9.10
    and apllied the given method (.deb and then modprob)
    and actually it works fine ! Even with rev ff.
    i still can see nvidia card white lspci
    but i saw 6W power drop when executing modprobe !
    (from 15W to 9W !). This is really cool ! Thanks for the tips, and i'm waiting for a real support for hybrid cards ;)

    cheers

    ReplyDelete
  11. @osman : open the makefile, replace the "space" before the two "$(MAKE)" by a backspace, save your makefile and relaunch the make command.

    ReplyDelete
  12. Will this work with ASUS U30Jc, with NVIDIA ION2 (or "Optimus") technology? Would be sweet to run its NVIDIA on Linux... (I can't test myself, I'm just considering to buy that model... it would be really great if only it was supported with Linux...).

    ReplyDelete
  13. There is info re optimus and linux here:
    http://linux-hybrid-graphics.blogspot.com/

    ReplyDelete
  14. It does not seems to work and i don't understand why.
    I'm on an UL50VT with geforce G210m and ubuntu karmic, but i've the same result as maigre, and with powertop i've 10,7W.
    Could you help me ? (i bought this laptop because of its long battery time , but i've only 2hours..)

    ReplyDelete
  15. Mael: Maigre's post has been revised. He confirmed that it works on his Ubuntu 9.10.

    ReplyDelete
  16. Note that this blog messes up the makefile, you'll need to replace the spaces in front of "$(MAKE)" with a tab instead.

    ReplyDelete
  17. Doesn't work for me on ubuntu 10.04/Lucid

    ReplyDelete
  18. Sorry, I should be more specific. On my UL30Vt running the current Lucid/10.04 it compiles, loads, get a dmesg saying "Disabling nvidia card" or similar then hangs few seconds later (often I have time to start powertop). The instance I do the modprobe the screen goes completely dark (including the backlight). This seems to happen if I'm running X11 or not.

    ReplyDelete
  19. Ah, turns out it mostly works. I thought I had disabled the nvidia card, but it turns out I was using the noveau driver on the nvidia card. So now it works is I modprobe. But if I add it to /etc/modules I get a hang before X11 starts. Does it make sense that X11 has to be started (and the intel gpu initialized) before disabling the nvidia GPU?

    ReplyDelete
  20. @Bill: It's difficult to say for me. Can you subscribe to https://launchpad.net/~asus-ul30 and ask the mailing list?

    ReplyDelete
  21. I only see the nvidia card active.

    lspci | grep -i VGA

    01:00.0 VGA compatible controller: nVidia Corporation GT218 [GeForce G210M] (rev a2)

    How can I activate the intel video card too? Thanks!

    ReplyDelete
  22. Hi,

    I've got an Asus ul80vt and I'm a newbie with Linux. I installed Ubuntu 10.4 and it runs quite well. Could it be possible to have the nvidia-package for Lucid Lynx ? Thanks for your help
    xaxapa@gmail.com

    ReplyDelete
  23. Can somebody post their xorg.conf? I am having issues getting the nVidia card to work period, and I think that might help.

    ReplyDelete
  24. Hi, this can run on my asus k52jc?

    ReplyDelete
  25. @fiox: the K52JC has this method:

    _SB.PCI0.PEG1.GFX0.DOFF
    _SB.PCI0.PEG1.GFX0.DON

    so you should be able to call it once acpi_call is installed in your laptop

    ReplyDelete
  26. http://linux-hybrid-graphics.blogspot.com/2010/07/using-acpicall-module-to-switch-onoff.html

    ReplyDelete
  27. hi avilella, thanks for the quick response. I already tried to compile acpi_call but i have an error when run make. You need the kernel 2.6.34?

    ReplyDelete
  28. @fiox: it should compile with the latest git version of acpi_call on older kernels than 2.6.34. I got it to work on 2.6.32

    ReplyDelete
  29. On kernel 2.6.32 I could not make it work. On 2.6.34 compiles and seems to work :D. I checked because if you launch echo '\_SB.PCI0.PEG1.GFX0.DON' > /proc/acpi/call
    the maximum remaining battery falls. And if you launch echo '\_SB.PCI0.PEG1.GFX0.DOFF' > /proc/acpi/call battery life rises again.
    There is another way to test the switch?
    test_off.sh not work on my laptop

    ReplyDelete
  30. Mend, now I work test_off.sh work. cat /proc/acpi/call returns ok, but after giving the first time cat /proc/acpi/call starts to return not Called. How do I check the current video card used?

    ReplyDelete
  31. I have this working on the N61JV with acpi call on kernel
    2.6.34 stable .
    vgaswitcheroo also compiles but spits kernel oops and locks up ,even with the correct firmware .
    Cant get nvidia module to bind to the adapter even after a recompile after header changes.

    Nouveau module has to be loaded to enable switcheroo.

    Logs confirm the nvidia i2c adapter is recognised.
    but i still have vbios errors even after switching this off .

    acpi call module works with all graphics relevant commands from the DSDT .

    Has anyone found the nvidia adapter binding to qither
    of the nv,nouveau,nvidia modules .?

    ReplyDelete
  32. On Lucid I am showing I am still sucking 13 w after doing the modprobe. I added the module to etc/modules, rebooted and it still sucking 12-14 w.

    ReplyDelete
  33. @Jason Smith:

    Can you try the acpi_call module as explained at the header of the page here: http://linux-hybrid-graphics.blogspot.com/

    Cheers

    ReplyDelete
  34. hello everyone,

    I have got a UL80VT and up to now I had the problem, that when I left the internal graphic activated the screen stayed black: I fixed that with changing a setting in the BIOS that deactivated the internal graphic. Now I used the package mentioned in this post and modeprobe'd and the screen stays black, unfortunately. Even when I activated the internal graphic again it stayed =/. What can I do to reverse the effect of the package in this situation?

    ReplyDelete
  35. You need to change from compatability mode.

    ReplyDelete
  36. @avilella It installed fine. I ran test.sh. I am still sucking 13w. At least according to powertop.
    I didn't see anything specific for the ul series and turning off graphics.

    ReplyDelete
  37. disregard my last post. After restarting X the power consumptions went down around 4w.

    I just need to use the rest of the power saving features.

    ReplyDelete
  38. utro pod kaw...ambot..hahay..i love this site...maybe i could make it some of my reference...thanks for showing it to me...


    beware of scammer sites for your dessertation....
    bestessays.com scam

    regards,
    badloi

    ReplyDelete
  39. I installed the .deb but when I try to run "sudo modprobe nvidia_g210m_acpi" I get "FATAL: Module nvidia_g210m_acpi not found."

    I have an Asus ul30vt with Maverick Meerkat.. No go with 10.10?

    ReplyDelete