Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
c7dbd6babb | |||
2822d1630c | |||
c665a74def | |||
e21cdd7b3f | |||
f982a09546 | |||
3e50c7b118 | |||
91814c63f1 |
6
NEWS
6
NEWS
@ -1,3 +1,9 @@
|
|||||||
|
Version 0.7 - 28 May 2013
|
||||||
|
|
||||||
|
* Fixes a scary WARNING on Linux 3.9.
|
||||||
|
* Improved debug information when an ACPI method cannot be executed.
|
||||||
|
* Added copyright information, update my name.
|
||||||
|
|
||||||
Version 0.6 - 19 March 2013
|
Version 0.6 - 19 March 2013
|
||||||
|
|
||||||
* Add workaround for Linux 3.8 regression (not present in earlier or latter
|
* Add workaround for Linux 3.8 regression (not present in earlier or latter
|
||||||
|
31
README.md
31
README.md
@ -22,6 +22,16 @@ detect the correct handle preceding _DSM and has some built-in safeguards:
|
|||||||
disabled again if that was the case before suspending. Hibernation should
|
disabled again if that was the case before suspending. Hibernation should
|
||||||
work, but it not tested.
|
work, but it not tested.
|
||||||
|
|
||||||
|
Precautionary measure :
|
||||||
|
- On some machines, turning off the card is permanent and the card does not
|
||||||
|
reappear on subsequents reboots, which can result into the screen staying
|
||||||
|
black all the time, including the BIOS screen.
|
||||||
|
If it occurs, first try to shutdown, unplug power cord, remove battery, wait
|
||||||
|
30s, then put everything back in and boot. If it's not solved, then the
|
||||||
|
solution is to reset the BIOS to factory settings. Before executing bbswitch
|
||||||
|
for the first time, it is therefore recommended to take note of the full key
|
||||||
|
sequence in the BIOS to do a reset.
|
||||||
|
|
||||||
Build
|
Build
|
||||||
-----
|
-----
|
||||||
|
|
||||||
@ -94,8 +104,9 @@ same behavior as:
|
|||||||
If not explictly set, the default behavior is not to change the power state of
|
If not explictly set, the default behavior is not to change the power state of
|
||||||
the discrete video card which equals to `load_state=-1 unload_state=-1`.
|
the discrete video card which equals to `load_state=-1 unload_state=-1`.
|
||||||
|
|
||||||
The Lenovo T410s laptop needs the module option `skip_optimus_dsm=1`, otherwise
|
The Lenovo T410 and Lenovo T410s laptops need the module option
|
||||||
it will detect the wrong methods which result in the card not being disabled.
|
`skip_optimus_dsm=1`, otherwise it will detect the wrong methods which result in
|
||||||
|
the card not being disabled.
|
||||||
|
|
||||||
### Disable card on boot
|
### Disable card on boot
|
||||||
|
|
||||||
@ -106,10 +117,26 @@ get disabled on boot:
|
|||||||
|
|
||||||
bbswitch load_state=0
|
bbswitch load_state=0
|
||||||
|
|
||||||
|
Users of `kmod` should create `/etc/modprobe.d/bbswitch.conf` containing
|
||||||
|
`options bbswitch load_state=0` to set the default options. To load the module,
|
||||||
|
systemd users should create `/etc/modules-load.d/bbswitch.conf` containing
|
||||||
|
`bbswitch`.
|
||||||
|
|
||||||
You have to update your initial ramdisk (initrd) for the changes propagate to
|
You have to update your initial ramdisk (initrd) for the changes propagate to
|
||||||
the boot process. On Debian and Ubuntu, this can performed by running
|
the boot process. On Debian and Ubuntu, this can performed by running
|
||||||
`update-initramfs -u` as root.
|
`update-initramfs -u` as root.
|
||||||
|
|
||||||
|
### Enable card on shutdown
|
||||||
|
|
||||||
|
Some machines do not like the card being disabled at shutdown.
|
||||||
|
Add the next initscript (`/etc/init/bbswitch.conf`) :
|
||||||
|
description "Save power by disabling nvidia on Optimus"
|
||||||
|
author "Lekensteyn <lekensteyn@gmail.com>"
|
||||||
|
start on runlevel [2345]
|
||||||
|
stop on runlevel [016]
|
||||||
|
pre-start exec /sbin/modprobe bbswitch load_state=0 unload_state=1
|
||||||
|
pre-stop exec /sbin/rmmod bbswitch
|
||||||
|
|
||||||
Reporting bugs
|
Reporting bugs
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
21
bbswitch.c
21
bbswitch.c
@ -10,6 +10,9 @@
|
|||||||
* # cat /proc/acpi/bbswitch
|
* # cat /proc/acpi/bbswitch
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
|
* Copyright (C) 2011-2013 Bumblebee Project
|
||||||
|
* Author: Peter Wu <lekensteyn@gmail.com>
|
||||||
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
@ -33,11 +36,11 @@
|
|||||||
#include <linux/seq_file.h>
|
#include <linux/seq_file.h>
|
||||||
#include <linux/pm_runtime.h>
|
#include <linux/pm_runtime.h>
|
||||||
|
|
||||||
#define BBSWITCH_VERSION "0.6"
|
#define BBSWITCH_VERSION "0.7"
|
||||||
|
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
MODULE_DESCRIPTION("Toggle the discrete graphics card");
|
MODULE_DESCRIPTION("Toggle the discrete graphics card");
|
||||||
MODULE_AUTHOR("Peter Lekensteyn <lekensteyn@gmail.com>");
|
MODULE_AUTHOR("Peter Wu <lekensteyn@gmail.com>");
|
||||||
MODULE_VERSION(BBSWITCH_VERSION);
|
MODULE_VERSION(BBSWITCH_VERSION);
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -129,10 +132,14 @@ static int acpi_call_dsm(acpi_handle handle, const char muid[16], int revid,
|
|||||||
|
|
||||||
err = acpi_evaluate_object(handle, "_DSM", &input, &output);
|
err = acpi_evaluate_object(handle, "_DSM", &input, &output);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL };
|
||||||
char muid_str[5 * 16];
|
char muid_str[5 * 16];
|
||||||
char args_str[5 * 4];
|
char args_str[5 * 4];
|
||||||
|
|
||||||
pr_warn("failed to evaluate _DSM {%s} 0x%X 0x%X {%s}: %s\n",
|
acpi_get_name(handle, ACPI_FULL_PATHNAME, &buf);
|
||||||
|
|
||||||
|
pr_warn("failed to evaluate %s._DSM {%s} 0x%X 0x%X {%s}: %s\n",
|
||||||
|
(char *)buf.pointer,
|
||||||
buffer_to_string(muid, 16, muid_str), revid, func,
|
buffer_to_string(muid, 16, muid_str), revid, func,
|
||||||
buffer_to_string(args, 4, args_str), acpi_format_exception(err));
|
buffer_to_string(args, 4, args_str), acpi_format_exception(err));
|
||||||
return err;
|
return err;
|
||||||
@ -431,7 +438,7 @@ static int __init bbswitch_init(void) {
|
|||||||
/* At least two Acer machines are known to use the intel ACPI handle
|
/* At least two Acer machines are known to use the intel ACPI handle
|
||||||
* with the legacy nvidia DSM */
|
* with the legacy nvidia DSM */
|
||||||
dis_handle = igd_handle;
|
dis_handle = igd_handle;
|
||||||
if (has_dsm_func(acpi_nvidia_dsm_muid, 0x102, 0x3)) {
|
if (dis_handle && has_dsm_func(acpi_nvidia_dsm_muid, 0x102, 0x3)) {
|
||||||
dsm_type = DSM_TYPE_NVIDIA;
|
dsm_type = DSM_TYPE_NVIDIA;
|
||||||
pr_info("detected a nVidia _DSM function on the"
|
pr_info("detected a nVidia _DSM function on the"
|
||||||
" integrated video card\n");
|
" integrated video card\n");
|
||||||
@ -449,6 +456,12 @@ static int __init bbswitch_init(void) {
|
|||||||
|
|
||||||
dis_dev_get();
|
dis_dev_get();
|
||||||
|
|
||||||
|
if (!is_card_disabled()) {
|
||||||
|
/* We think the card is enabled, so ensure the kernel does as well */
|
||||||
|
if (pci_enable_device(dis_dev))
|
||||||
|
pr_warn("failed to enable %s\n", dev_name(&dis_dev->dev));
|
||||||
|
}
|
||||||
|
|
||||||
if (load_state == CARD_ON)
|
if (load_state == CARD_ON)
|
||||||
bbswitch_on();
|
bbswitch_on();
|
||||||
else if (load_state == CARD_OFF)
|
else if (load_state == CARD_OFF)
|
||||||
|
Reference in New Issue
Block a user