From: Dave Airlie <[email protected]>

When nothing is connected at startup and we canGrow, allow the server to start 
with a 1024x768 framebuffer, and when the drivers send hotplug events this will 
expand to the correct size dynamically.

Signed-off-by: Dave Airlie <[email protected]>
---
 hw/xfree86/modes/xf86Crtc.c |   61 +++++++++++++++++++++++++++++++------------
 1 files changed, 44 insertions(+), 17 deletions(-)

diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 1ccaffc..3ed0810 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -46,6 +46,8 @@
 
 #include "xf86xv.h"
 
+#define NO_OUTPUT_DEFAULT_WIDTH 1024
+#define NO_OUTPUT_DEFAULT_HEIGHT 768
 /*
  * Initialize xf86CrtcConfig structure
  */
@@ -1921,7 +1923,7 @@ xf86SetScrnInfoModes (ScrnInfoPtr scrn)
 #endif
 }
 
-static void
+static Bool
 xf86CollectEnabledOutputs(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
                          Bool *enabled)
 {
@@ -1936,8 +1938,10 @@ xf86CollectEnabledOutputs(ScrnInfoPtr scrn, 
xf86CrtcConfigPtr config,
                   "No outputs definitely connected, trying again...\n");
 
        for (o = 0; o < config->num_output; o++)
-           enabled[o] = xf86OutputEnabled(config->output[o], FALSE);
+           any_enabled |= enabled[o] = xf86OutputEnabled(config->output[o], 
FALSE);
     }
+
+    return any_enabled;
 }
 
 static Bool
@@ -2337,6 +2341,8 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
     Bool               *enabled;
     int                        width, height;
     int                        i = scrn->scrnIndex;
+    Bool have_outputs = TRUE;
+    Bool ret;
 
     /* Set up the device options */
     config->options = xnfalloc (sizeof (xf86DeviceOptions));
@@ -2362,18 +2368,23 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool 
canGrow)
     modes = xnfcalloc (config->num_output, sizeof (DisplayModePtr));
     enabled = xnfcalloc (config->num_output, sizeof (Bool));
     
-    xf86CollectEnabledOutputs(scrn, config, enabled);
-
-    if (xf86TargetUserpref(scrn, config, modes, enabled, width, height))
-       xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n");
-    else if (xf86TargetPreferred(scrn, config, modes, enabled, width, height))
-       xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n");
-    else if (xf86TargetAspect(scrn, config, modes, enabled, width, height))
-       xf86DrvMsg(i, X_INFO, "Using fuzzy aspect match for initial modes\n");
-    else if (xf86TargetFallback(scrn, config, modes, enabled, width, height))
-       xf86DrvMsg(i, X_INFO, "Using sloppy heuristic for initial modes\n");
-    else
-       xf86DrvMsg(i, X_WARNING, "Unable to find initial modes\n");
+    ret = xf86CollectEnabledOutputs(scrn, config, enabled);
+    if (ret == FALSE && canGrow) {
+       xf86DrvMsg(i, X_WARNING, "Unable to find connected outputs - setting 
%dx%d initial framebuffer\n",
+                  NO_OUTPUT_DEFAULT_WIDTH, NO_OUTPUT_DEFAULT_HEIGHT);
+       have_outputs = FALSE;
+    } else {
+       if (xf86TargetUserpref(scrn, config, modes, enabled, width, height))
+           xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n");
+       else if (xf86TargetPreferred(scrn, config, modes, enabled, width, 
height))
+           xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n");
+       else if (xf86TargetAspect(scrn, config, modes, enabled, width, height))
+           xf86DrvMsg(i, X_INFO, "Using fuzzy aspect match for initial 
modes\n");
+       else if (xf86TargetFallback(scrn, config, modes, enabled, width, 
height))
+           xf86DrvMsg(i, X_INFO, "Using sloppy heuristic for initial modes\n");
+       else
+           xf86DrvMsg(i, X_WARNING, "Unable to find initial modes\n");
+    }
 
     for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
        if (!modes[o])
@@ -2404,7 +2415,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
     /*
      * Assign CRTCs to fit output configuration
      */
-    if (!xf86PickCrtcs (scrn, crtcs, modes, 0, width, height))
+    if (have_outputs && !xf86PickCrtcs (scrn, crtcs, modes, 0, width, height))
     {
        xfree (crtcs);
        xfree (modes);
@@ -2466,6 +2477,13 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
         */
        xf86DefaultScreenLimits (scrn, &width, &height, canGrow);
     
+       if (have_outputs == FALSE) {
+           if (width < NO_OUTPUT_DEFAULT_WIDTH && height < 
NO_OUTPUT_DEFAULT_HEIGHT) {
+               width = NO_OUTPUT_DEFAULT_WIDTH;
+               height = NO_OUTPUT_DEFAULT_HEIGHT;
+           }
+       }
+
        scrn->display->virtualX = width;
        scrn->display->virtualY = height;
     }
@@ -2491,8 +2509,17 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
                              width, height);
     }
 
-    /* Mirror output modes to scrn mode list */
-    xf86SetScrnInfoModes (scrn);
+    if (have_outputs) {
+       /* Mirror output modes to scrn mode list */
+       xf86SetScrnInfoModes (scrn);
+    } else {
+       /* Clear any existing modes from scrn->modes */
+       while (scrn->modes != NULL)
+           xf86DeleteMode(&scrn->modes, scrn->modes);
+       scrn->modes = xf86ModesAdd(scrn->modes,
+                                  xf86CVTMode(width, height, 60, 0, 0));
+    }
+
     
     xfree (crtcs);
     xfree (modes);
-- 
1.7.0.1

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to