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
|
||||
|
||||
* 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
|
||||
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
|
||||
-----
|
||||
|
||||
@ -94,8 +104,9 @@ same behavior as:
|
||||
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 Lenovo T410s laptop needs the module option `skip_optimus_dsm=1`, otherwise
|
||||
it will detect the wrong methods which result in the card not being disabled.
|
||||
The Lenovo T410 and Lenovo T410s laptops need the module option
|
||||
`skip_optimus_dsm=1`, otherwise it will detect the wrong methods which result in
|
||||
the card not being disabled.
|
||||
|
||||
### Disable card on boot
|
||||
|
||||
@ -106,10 +117,26 @@ get disabled on boot:
|
||||
|
||||
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
|
||||
the boot process. On Debian and Ubuntu, this can performed by running
|
||||
`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
|
||||
--------------
|
||||
|
||||
|
21
bbswitch.c
21
bbswitch.c
@ -10,6 +10,9 @@
|
||||
* # 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
@ -33,11 +36,11 @@
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
|
||||
#define BBSWITCH_VERSION "0.6"
|
||||
#define BBSWITCH_VERSION "0.7"
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
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);
|
||||
|
||||
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);
|
||||
if (err) {
|
||||
struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER, NULL };
|
||||
char muid_str[5 * 16];
|
||||
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(args, 4, args_str), acpi_format_exception(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
|
||||
* with the legacy nvidia DSM */
|
||||
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;
|
||||
pr_info("detected a nVidia _DSM function on the"
|
||||
" integrated video card\n");
|
||||
@ -449,6 +456,12 @@ static int __init bbswitch_init(void) {
|
||||
|
||||
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)
|
||||
bbswitch_on();
|
||||
else if (load_state == CARD_OFF)
|
||||
|
Reference in New Issue
Block a user