Skip to content
Browse files

Drop ENABLE_POWER_MANAGEMENT, support PM_METHOD (Closes GH-14)

ENABLE_POWER_MANAGEMENT was used solely for the apci_call method. Dropping this
as we now have other methods. In addition, debugging messages now show the name
of the chosen settings instead of a number. The PM_METHOD setting for using
vga_switcheroo has been changed from "vgaswitcheroo" to "switcheroo"
  • Loading branch information...
1 parent a859e86 commit 18b2b95949fd0868bce455c9378425209981b84a @Lekensteyn Lekensteyn committed Dec 31, 2011
Showing with 63 additions and 57 deletions.
  1. +7 −19 conf/bumblebee.conf
  2. +1 −1 configure.ac
  3. +22 −18 src/bbconfig.c
  4. +7 −6 src/bbconfig.h
  5. +23 −11 src/bbsecondary.c
  6. +2 −1 src/switch/switching.c
  7. +1 −1 src/switch/switching.h
View
26 conf/bumblebee.conf
@@ -35,26 +35,14 @@
# value is 'bumblebee'
#BUMBLEBEE_GROUP=bumblebee
-# Uncomment the line below to enable power management on the dedicated graphics
-# card. Bumblebee will try to use vga-switcheroo kernel module if 'nouveau' is
-# detected or set as DRIVER. If the module bbswitch is found Bumblebee will try
-# to use it. If 'nvidia' driver is used, you will need the bbswitch module for
-# power management to work.
-# WARNING ! Power management is an experimental feature for now, we are trying
-# to make it stable but don't complain to us unless you are whiling to help in
-# it's development.
-# See https://github.com/Bumblebee-Project/Bumblebee/wiki/ACPI-for-Developers
-# for more information.
-#ENABLE_POWER_MANAGEMENT=0
-
# Enable power management with the specified method. Possible values are
-# "auto" : Enable power switching with autodetection.
-# "bbswitch" : Enable power management and force to use bbswitch as method. If
-# bbswitch is not available, power management will be disabled.
-# "vgaswitcheroo" : Enable power management and force to use vgaswitcheroo as
-# method. If vgaswitcheroo is not available, power management will be disabled.
-# "none" : Power management disabled.
-# If not specified, "auto" will be used.
+# none - disable power management, just what the legacy ENABLE_POWER_MANAGEMENT
+# option (which is removed) did
+# auto - try to detect available methods (default if unspecified)
+# bbswitch - only try the bbswitch kernel module
+# switcheroo - only try vga_switcheroo which can only be used with nouveau
+# if a method is not available, PM will be disabled. See also:
+# https://github.com/Bumblebee-Project/Bumblebee/wiki/Comparison-of-PM-methods
#PM_METHOD=auto
# Uncomment the line below to set the card power state when the daemon exits.
View
2 configure.ac
@@ -13,7 +13,7 @@ AC_DEFINE(CONF_LDPATH, "/usr/lib64/nvidia-current:/usr/lib/nvidia-current:/usr/l
AC_DEFINE(CONF_MODPATH, ["/usr/lib64/nvidia-current/xorg,/usr/lib/nvidia-current/xorg,/usr/lib32/nvidia-current/xorg,/usr/lib64/nvidia/xorg,/usr/lib/nvidia/xorg,/usr/lib32/nvidia/xorg,/usr/lib/i386-linux-gnu/xorg/extra-modules,/usr/lib/x86_64-linux-gnu/xorg/extra-modules,/usr/lib64/xorg/extra-modules,/usr/lib64/xorg/modules,/usr/lib/xorg/extra-modules,/usr/lib/xorg/modules,/usr/lib32/xorg/extra-modules,/usr/lib32/xorg/modules"], "ModulePath for xorg")
AC_DEFINE(CONF_SOCKPATH, "/var/run/bumblebee.socket", "socket path")
AC_DEFINE(CONF_GID, "bumblebee", "group to use when setting GID")
-AC_DEFINE(CONF_PMENABLE, 1, "enable power management")
+AC_DEFINE(CONF_PM_METHOD, PM_AUTO, "Power management method")
AC_DEFINE(CONF_STOPONEXIT, 1, "stop secondary X on exit of last optirun executable")
AC_DEFINE(CONF_FALLBACKSTART, 1, "make optirun start applications normally if secondary is unavailable")
AC_DEFINE(CONF_VGLCOMPRESS, "proxy", "vglclient transport method")
View
40 src/bbconfig.c
@@ -37,6 +37,15 @@
#include "bblogger.h"
#include "module.h"
+/* config values for PM methods, edit bb_pm_method in bbconfig.h as well! */
+const char *bb_pm_method_string[PM_METHODS_COUNT] = {
+ "none",
+ "auto",
+ /* the below names are used in switch/switching.c */
+ "bbswitch",
+ "switcheroo",
+};
+
struct bb_status_struct bb_status;
struct bb_config_struct bb_config;
@@ -225,21 +234,17 @@ static int read_configuration(void) {
set_string_value(&bb_config.vgl_compress, kvp.value);
bb_log(LOG_DEBUG, "value set: vgl_compress = %s\n", bb_config.vgl_compress);
} else if (strcmp(kvp.key, "PM_METHOD") == 0) {
- if (strcmp(kvp.value, "auto") == 0) {
- bb_config.pm_method = PM_AUTO;
- } else if (strcmp(kvp.value, "bbswitch") == 0) {
- bb_config.pm_method = PM_BBSWITCH;
- } else if (strcmp(kvp.value, "vgaswitcheroo") == 0) {
- bb_config.pm_method = PM_VGASWITCHEROO;
- } else { // none
- bb_config.pm_method = PM_DISABLED;
+ /* loop backwards through all possible values. If no valid value is
+ * found, assume the first element ("none") */
+ int method_index = PM_METHODS_COUNT;
+ while (--method_index >= 0) {
+ if (strcmp(kvp.value, bb_pm_method_string[method_index]) == 0) {
+ break;
+ }
}
- bb_log(LOG_DEBUG, "value set: pm_method = %d\n", bb_config.pm_method);
- } else if (strcmp(kvp.key, "ENABLE_POWER_MANAGEMENT") == 0) {
- /* First step to deprecate ENABLE_POWER_MANAGEMENT */
- bb_log(LOG_WARNING, "Using deprecated method for enabling power management.");
- bb_config.pm_enabled = boolean_value(kvp.value);
- bb_log(LOG_DEBUG, "value set: pm_enabled = %d\n", bb_config.pm_enabled);
+ bb_config.pm_method = method_index;
+ bb_log(LOG_DEBUG, "value set: pm_method = %s\n",
+ bb_pm_method_string[method_index]);
} else if (strcmp(kvp.key, "FALLBACK_START") == 0) {
bb_config.fallback_start = boolean_value(kvp.value);
bb_log(LOG_DEBUG, "value set: fallback_start = %d\n", bb_config.fallback_start);
@@ -439,8 +444,7 @@ void init_config(int argc, char ** argv) {
// default to auto-detect
set_string_value(&bb_config.driver, "");
set_string_value(&bb_config.module_name, "");
- bb_config.pm_enabled = CONF_PMENABLE;
- bb_config.pm_method = PM_AUTO;
+ bb_config.pm_method = CONF_PM_METHOD;
bb_config.stop_on_exit = CONF_STOPONEXIT;
bb_config.fallback_start = CONF_FALLBACKSTART;
bb_config.card_shutdown_state = CONF_SHUTDOWNSTATE;
@@ -466,8 +470,8 @@ void config_dump(void) {
bb_log(LOG_DEBUG, " ModulePath: %s\n", bb_config.mod_path);
bb_log(LOG_DEBUG, " Socket path: %s\n", bb_config.socket_path);
bb_log(LOG_DEBUG, " GID name: %s\n", bb_config.gid_name);
- bb_log(LOG_DEBUG, " Power management: %i\n", bb_config.pm_enabled);
- bb_log(LOG_DEBUG, " Power method: %i\n", bb_config.pm_method);
+ bb_log(LOG_DEBUG, " Power method: %s\n",
+ bb_pm_method_string[bb_config.pm_method]);
bb_log(LOG_DEBUG, " Stop X on exit: %i\n", bb_config.stop_on_exit);
bb_log(LOG_DEBUG, " VGL Compression: %s\n", bb_config.vgl_compress);
bb_log(LOG_DEBUG, " Driver: %s\n", bb_config.driver);
View
13 src/bbconfig.h
@@ -48,13 +48,15 @@ enum bb_run_mode {
BB_RUN_EXIT = 99
};
-/* Power management methods */
+/* Power management methods, edit bb_pm_method_string in bbconfig.c as well! */
enum bb_pm_method {
- PM_DISABLED = 0,
- PM_AUTO = 1, // This will be a temporary state, as it would cahnge to the method available.
- PM_BBSWITCH = 2,
- PM_VGASWITCHEROO = 3
+ PM_DISABLED,
+ PM_AUTO, /* at detection time, this value will be changed */
+ PM_BBSWITCH,
+ PM_VGASWITCHEROO,
+ PM_METHODS_COUNT /* not a method but a marker for the end */
};
+const char *bb_pm_method_string[PM_METHODS_COUNT];
/* String buffer size */
#define BUFFER_SIZE 1024
@@ -79,7 +81,6 @@ struct bb_config_struct {
char * mod_path; /// ModulePath for xorg.
char * socket_path; /// Path to the server socket.
char * gid_name; /// Group name for setgid.
- int pm_enabled; /// Wether the power management feature is enabled
enum bb_pm_method pm_method; /// Which method to use for power management.
int stop_on_exit; /// Whether to stop the X server on last optirun instance exit.
int fallback_start; /// Wheter the application should be launched on the integrated card when X is not available.
View
34 src/bbsecondary.c
@@ -199,8 +199,9 @@ void stop_secondary() {
bb_stop_wait(bb_status.x_pid);
}
- if (!bb_config.pm_enabled && (bb_status.runmode != BB_RUN_EXIT)) {
- return; //do not switch card off if pm_enabled is false, unless exiting.
+ if (bb_config.pm_method == PM_DISABLED && bb_status.runmode != BB_RUN_EXIT) {
+ /* do not disable the card if PM is disabled unless exiting */
+ return;
}
//if card is on and can be switched, switch it off
@@ -262,15 +263,26 @@ void check_secondary(void) {
}
//check switch availability, warn if not availble
- struct switch_info info;
- memset(&info, 0, sizeof info);
- info.driver = bb_config.driver;
- switcher = switcher_detect(NULL, info);
- if (switcher) {
- bb_log(LOG_INFO, "Switching method '%s' is available and will be used.\n",
- switcher->name);
+ if (bb_config.pm_method == PM_DISABLED) {
+ bb_log(LOG_INFO, "PM is disabled, not performing detection.\n");
} else {
- bb_log(LOG_WARNING, "No switching method available. The dedicated card will"
- " always be on.\n");
+ struct switch_info info;
+ memset(&info, 0, sizeof info);
+ info.driver = bb_config.driver;
+
+ const char *pm_method = NULL;
+ if (bb_config.pm_method != PM_AUTO) {
+ /* auto-detection override */
+ pm_method = bb_pm_method_string[bb_config.pm_method];
+ }
+
+ switcher = switcher_detect(pm_method, info);
+ if (switcher) {
+ bb_log(LOG_INFO, "Switching method '%s' is available and will be used.\n",
+ switcher->name);
+ } else {
+ bb_log(LOG_WARNING, "No switching method available. The dedicated card"
+ " will always be on.\n");
+ }
}
}
View
3 src/switch/switching.c
@@ -40,7 +40,8 @@ struct switching_method switching_methods[SWITCHERS_COUNT] = {
* decision whether bbswitch is usable or not
* @return A switching method if available, NULL otherwise
*/
-struct switching_method *switcher_detect(char *name, struct switch_info info) {
+struct switching_method *switcher_detect(const char *name,
+ struct switch_info info) {
int i;
switcher = NULL;
for (i = 0; i<SWITCHERS_COUNT; ++i) {
View
2 src/switch/switching.h
@@ -64,7 +64,7 @@ struct switching_method switching_methods[SWITCHERS_COUNT];
/* A switching method that can be used or NULL if none */
struct switching_method *switcher;
-struct switching_method *switcher_detect(char *name, struct switch_info);
+struct switching_method *switcher_detect(const char *name, struct switch_info);
enum switch_state switch_status(void);
enum switch_state switch_on(void);
enum switch_state switch_off(void);

0 comments on commit 18b2b95

Please sign in to comment.
Something went wrong with that request. Please try again.