[PATCH 10/36] xfree86: add autoAddGPU option (v2)

Dave Airlie airlied at gmail.com
Thu Jul 5 08:21:11 PDT 2012


From: Dave Airlie <airlied at redhat.com>

This option is to stop the X server adding non-primary devices as
gpu screens.

v2: fix per Keith's suggestion.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 hw/xfree86/common/xf86Config.c      |   15 ++++++++++++++-
 hw/xfree86/common/xf86Globals.c     |    9 +++++++--
 hw/xfree86/common/xf86Privstr.h     |    2 ++
 hw/xfree86/common/xf86platformBus.c |    7 +++++++
 4 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index b22b617..edc0d3d 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -712,7 +712,8 @@ typedef enum {
     FLAG_AUTO_ENABLE_DEVICES,
     FLAG_GLX_VISUALS,
     FLAG_DRI2,
-    FLAG_USE_SIGIO
+    FLAG_USE_SIGIO,
+    FLAG_AUTO_ADD_GPU,
 } FlagValues;
 
 /**
@@ -770,6 +771,8 @@ static OptionInfoRec FlagOptions[] = {
      {0}, FALSE},
     {FLAG_USE_SIGIO, "UseSIGIO", OPTV_BOOLEAN,
      {0}, FALSE},
+    {FLAG_AUTO_ADD_GPU, "AutoAddGPU", OPTV_BOOLEAN,
+     {0}, FALSE},
     {-1, NULL, OPTV_NONE,
      {0}, FALSE},
 };
@@ -862,6 +865,16 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
     xf86Msg(from, "%sutomatically enabling devices\n",
             xf86Info.autoEnableDevices ? "A" : "Not a");
 
+    if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ADD_GPU)) {
+        xf86GetOptValBool(FlagOptions, FLAG_AUTO_ADD_GPU,
+                          &xf86Info.autoAddGPU);
+        from = X_CONFIG;
+    }
+    else {
+        from = X_DEFAULT;
+    }
+    xf86Msg(from, "%sutomatically adding GPU devices\n",
+            xf86Info.autoAddGPU ? "A" : "Not a");
     /*
      * Set things up based on the config file information.  Some of these
      * settings may be overridden later when the command line options are
diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c
index bb08917..7df7a80 100644
--- a/hw/xfree86/common/xf86Globals.c
+++ b/hw/xfree86/common/xf86Globals.c
@@ -126,11 +126,16 @@ xf86InfoRec xf86Info = {
 #if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS)
     .forceInputDevices = FALSE,
     .autoAddDevices = TRUE,
-    .autoEnableDevices = TRUE
+    .autoEnableDevices = TRUE,
 #else
     .forceInputDevices = TRUE,
     .autoAddDevices = FALSE,
-    .autoEnableDevices = FALSE
+    .autoEnableDevices = FALSE,
+#endif
+#if defined(CONFIG_UDEV_KMS)
+    .autoAddGPU = TRUE,
+#else
+    .autoAddGPU = FALSE,
 #endif
 };
 
diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h
index e78cd40..e20be03 100644
--- a/hw/xfree86/common/xf86Privstr.h
+++ b/hw/xfree86/common/xf86Privstr.h
@@ -110,6 +110,8 @@ typedef struct {
 
     Bool dri2;
     MessageType dri2From;
+
+    Bool autoAddGPU;
 } xf86InfoRec, *xf86InfoPtr;
 
 #ifdef DPMSExtension
diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
index 0cc6c0a..3bfb22e 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -373,6 +373,13 @@ xf86platformProbeDev(DriverPtr drvp)
             continue;
     }
 
+    /* if autoaddgpu devices is enabled then go find a few more and add them as GPU screens */
+    if (xf86Info.autoAddGPU && numDevs) {
+        for (j = 0; j < xf86_num_platform_devices; j++) {
+            probeSingleDevice(&xf86_platform_devices[j], drvp, devList[0], PLATFORM_PROBE_GPU_SCREEN);
+        }
+    }
+
     return foundScreen;
 }
 
-- 
1.7.10.2



More information about the xorg-devel mailing list