Dear Philipp, dear all, On So, 07 Jun 2009, Philipp Blanke wrote: > I just compiled a tutorial for the configuration of the graphic cards. See > the attached ODT or PDF.
First of all thanks for the tutorial, much appreciated, and it worked like a charm here on Debian/sid. > Feedback welcome. Please point out errors. Two shutdown-reboot cycles were necessary on my laptop since I have never before played around with switching graphics cards. Another more important thing is energy saving. When loading sony-laptop with speed_stamina=3 nothing is touched at the graphics card side, so the other (not working) graphics card is not actually turned off, means it takes much more energy. Fortunately Matthew has written a simple module nvidia_control that turns off the nvidia graphic card. So I have adjusted your /etc/init.d/switch-graphics so that in the Intel section it does modprobe nvidia-control To make sure that nvidia-control is NOT loaded by default I also put blacklist nvidia-control into /etc/modprobe.d/sony-laptop.conf Combining those two I can get again down to 10W on battery. For completeness I attached the last code I have seen from Matthew for nvidia-control.c and the Makefile. Best wishes Norbert ------------------------------------------------------------------------------- Dr. Norbert Preining <prein...@logic.at> Vienna University of Technology Debian Developer <prein...@debian.org> Debian TeX Group gpg DSA: 0x09C5B094 fp: 14DF 2E6C 0307 BE6D AD76 A9C0 D2BF 4AA3 09C5 B094 ------------------------------------------------------------------------------- SCRABBY (n.) A curious-shaped duster given to you by your mother which on closer inspection turns out to be half an underpant. --- Douglas Adams, The Meaning of Liff
obj-m += nvidia-control.o all: make -C /lib/modules/`uname -r`/build M=`pwd`
#include <linux/acpi.h> #include <acpi/acpi_drivers.h> #include <acpi/acpi_bus.h> #include <linux/pci.h> static int nvidia_dsm(struct pci_dev *dev, int func, int arg, int *result) { static char muid[] = { 0xA0, 0xA0, 0x95, 0x9D, 0x60, 0x00, 0x48, 0x4D, 0xB3, 0x4D, 0x7E, 0x5F, 0xEA, 0x12, 0x9F, 0xD4, }; struct acpi_handle *handle; struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_object_list input; union acpi_object params[4]; union acpi_object *obj; int err; handle = DEVICE_ACPI_HANDLE(&dev->dev); if (!handle) return -ENODEV; input.count = 4; input.pointer = params; params[0].type = ACPI_TYPE_BUFFER; params[0].buffer.length = sizeof(muid); params[0].buffer.pointer = (char *)muid; params[1].type = ACPI_TYPE_INTEGER; params[1].integer.value = 0x00000102; params[2].type = ACPI_TYPE_INTEGER; params[2].integer.value = func; params[3].type = ACPI_TYPE_INTEGER; params[3].integer.value = arg; err = acpi_evaluate_object(handle, "_DSM", &input, &output); if (err) { printk(KERN_ERR "nvidia-control: failed to evaluate _DSM: %d\n", err); return err; } obj = (union acpi_object *)output.pointer; if (obj->type == ACPI_TYPE_INTEGER) if (obj->integer.value == 0x80000002) return -ENODEV; if (obj->type == ACPI_TYPE_BUFFER) { if (obj->buffer.length == 4 && result) { *result = 0; *result |= obj->buffer.pointer[0]; *result |= (obj->buffer.pointer[1] << 8); *result |= (obj->buffer.pointer[2] << 16); *result |= (obj->buffer.pointer[3] << 24); } } kfree(output.pointer); return 0; } int nvidia_control_setup(struct pci_dev *dev) { int result; if (nvidia_dsm(dev, 1, 0, &result)) return -ENODEV; printk(KERN_INFO "nvidia-control: hardware status gave 0x%x\n", result); if (result &= 0x1) { /* Stamina mode - disable the external GPU */ nvidia_dsm(dev, 0x2, 0x11, NULL); nvidia_dsm(dev, 0x3, 0x02, NULL); } else { /* Ensure that the external GPU is enabled */ nvidia_dsm(dev, 0x2, 0x12, NULL); nvidia_dsm(dev, 0x3, 0x01, NULL); } return 0; } int nvidia_control_probe(struct pci_dev *dev) { int support = 0; if (nvidia_dsm(dev, 0, 0, &support)) return -ENODEV; if (!support) return -ENODEV; return 0; } static int __init nvidia_control_init(void) { struct pci_dev *dev = NULL; while ((dev = pci_get_device(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, dev))) { if (dev->class == 0x30000) if (!nvidia_control_probe(dev)) nvidia_control_setup(dev); } return 0; } static void __exit nvidia_control_exit(void) { return; } static const struct pci_device_id pci_ids [] = { { PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, (PCI_CLASS_DISPLAY_VGA << 8), 0xffff00}, { }, }; MODULE_DEVICE_TABLE(pci, pci_ids); module_init(nvidia_control_init); module_exit(nvidia_control_exit); MODULE_LICENSE("GPL");
_______________________________________________ Mailing list: https://launchpad.net/~sony-vaio-z-series Post to : sony-vaio-z-series@lists.launchpad.net Unsubscribe : https://launchpad.net/~sony-vaio-z-series More help : https://help.launchpad.net/ListHelp