[PATCH 1/3] xf86Crtc: right-of placement by default.

Dave Airlie airlied at gmail.com
Tue Mar 31 21:32:45 PDT 2015


From: Adam Jackson <ajax at redhat.com>

Change the X server default to do right-of placement
at startup. This gives an option to allow drivers to
override this placement, which has been used for server
drivers where both heads are not in the same physical
place.

Been in Fedora for a few years, but for tiled monitors
we really want something along these lines.

This is an ABI break.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 hw/xfree86/common/xf86str.h |  6 ++++
 hw/xfree86/modes/xf86Crtc.c | 76 ++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 74 insertions(+), 8 deletions(-)

diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index 62c0ce9..a58fafe 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -516,6 +516,9 @@ typedef struct _confdrirec {
 #define NUM_RESERVED_POINTERS		14
 #define NUM_RESERVED_FUNCS		10
 
+/* let clients know they can use this */
+#define XF86_SCRN_HAS_PREFER_CLONE 1
+
 typedef void *(*funcPointer) (void);
 
 /* flags for depth 24 pixmap options */
@@ -772,6 +775,9 @@ typedef struct _ScrnInfoRec {
     ClockRangePtr clockRanges;
     int adjustFlags;
 
+    /* initial rightof support disable */
+    int                 preferClone;
+
     /*
      * These can be used when the minor ABI version is incremented.
      * The NUM_* parameters must be reduced appropriately to keep the
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index a194724..8a4ef5e 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -1123,6 +1123,15 @@ xf86InitialOutputPositions(ScrnInfoPtr scrn, DisplayModePtr * modes)
     int o;
     int min_x, min_y;
 
+    /* check for initial right-of heuristic */
+    for (o = 0; o < config->num_output; o++)
+    {
+        xf86OutputPtr output = config->output[o];
+
+        if (output->initial_x || output->initial_y)
+            return TRUE;
+    }
+
     for (o = 0; o < config->num_output; o++) {
         xf86OutputPtr output = config->output[o];
 
@@ -2102,6 +2111,57 @@ bestModeForAspect(xf86CrtcConfigPtr config, Bool *enabled, float aspect)
     return match;
 }
 
+static int
+numEnabledOutputs(xf86CrtcConfigPtr config, Bool *enabled)
+{
+    int i = 0, p;
+
+    for (i = 0, p = -1; nextEnabledOutput(config, enabled, &p); i++) ;
+
+    return i;
+}
+
+static Bool
+xf86TargetRightOf(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
+                  DisplayModePtr *modes, Bool *enabled,
+                  int width, int height)
+{
+    int o;
+    int w = 0;
+
+    if (scrn->preferClone)
+        return FALSE;
+
+    if (numEnabledOutputs(config, enabled) < 2)
+        return FALSE;
+
+    for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
+        DisplayModePtr mode =
+            xf86OutputHasPreferredMode(config->output[o], width, height);
+
+        if (!mode)
+            return FALSE;
+
+        w += mode->HDisplay;
+    }
+
+    if (w > width)
+        return FALSE;
+
+    w = 0;
+    for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
+        DisplayModePtr mode =
+            xf86OutputHasPreferredMode(config->output[o], width, height);
+
+        config->output[o]->initial_x = w;
+        w += mode->HDisplay;
+
+        modes[o] = mode;
+    }
+
+    return TRUE;
+}
+
 static Bool
 xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
                     DisplayModePtr * modes, Bool *enabled,
@@ -2178,14 +2238,10 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
      */
     if (!ret)
         do {
-            int i = 0;
             float aspect = 0.0;
             DisplayModePtr a = NULL, b = NULL;
 
-            /* count the number of enabled outputs */
-            for (i = 0, p = -1; nextEnabledOutput(config, enabled, &p); i++);
-
-            if (i != 1)
+            if (numEnabledOutputs(config, enabled) != 1)
                 break;
 
             p = -1;
@@ -2491,6 +2547,8 @@ xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow)
     else {
         if (xf86TargetUserpref(scrn, config, modes, enabled, width, height))
             xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n");
+        else if (xf86TargetRightOf(scrn, config, modes, enabled, width, height))
+            xf86DrvMsg(i, X_INFO, "Using spanning desktop for initial modes\n");
         else if (xf86TargetPreferred
                  (scrn, config, modes, enabled, width, height))
             xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n");
@@ -2510,9 +2568,11 @@ xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow)
                        "Output %s enabled but has no modes\n",
                        config->output[o]->name);
         else
-            xf86DrvMsg(scrn->scrnIndex, X_INFO,
-                       "Output %s using initial mode %s\n",
-                       config->output[o]->name, modes[o]->name);
+            xf86DrvMsg (scrn->scrnIndex, X_INFO,
+                        "Output %s using initial mode %s +%d+%d\n",
+                        config->output[o]->name, modes[o]->name,
+                        config->output[o]->initial_x,
+                        config->output[o]->initial_y);
     }
 
     /*
-- 
2.3.3



More information about the xorg-devel mailing list