1 From b27f93c6dbe0a6e416db2c65738e996c70a403c1 Mon Sep 17 00:00:00 2001
2 From: Fedora X Ninjas <airlied@redhat.com>
3 Date: Thu, 6 May 2010 12:55:34 +1000
4 Subject: [PATCH] xf86: allow for no outputs connected at startup operation.
6 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.
8 Signed-off-by: Dave Airlie <airlied@redhat.com>
10 hw/xfree86/modes/xf86Crtc.c | 66 ++++++++++++++++++++++++++++++------------
11 1 files changed, 47 insertions(+), 19 deletions(-)
13 diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
14 index 571ffd0..99082ec 100644
15 --- a/hw/xfree86/modes/xf86Crtc.c
16 +++ b/hw/xfree86/modes/xf86Crtc.c
21 +#define NO_OUTPUT_DEFAULT_WIDTH 1024
22 +#define NO_OUTPUT_DEFAULT_HEIGHT 768
24 * Initialize xf86CrtcConfig structure
26 @@ -1946,7 +1948,7 @@ xf86SetScrnInfoModes (ScrnInfoPtr scrn)
32 xf86CollectEnabledOutputs(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
35 @@ -1961,8 +1963,10 @@ xf86CollectEnabledOutputs(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
36 "No outputs definitely connected, trying again...\n");
38 for (o = 0; o < config->num_output; o++)
39 - enabled[o] = xf86OutputEnabled(config->output[o], FALSE);
40 + any_enabled |= enabled[o] = xf86OutputEnabled(config->output[o], FALSE);
47 @@ -2409,6 +2413,8 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
50 int i = scrn->scrnIndex;
51 + Bool have_outputs = TRUE;
54 /* Set up the device options */
55 config->options = xnfalloc (sizeof (xf86DeviceOptions));
56 @@ -2433,20 +2439,26 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
57 modes = xnfcalloc (config->num_output, sizeof (DisplayModePtr));
58 enabled = xnfcalloc (config->num_output, sizeof (Bool));
60 - xf86CollectEnabledOutputs(scrn, config, enabled);
62 - if (xf86TargetUserpref(scrn, config, modes, enabled, width, height))
63 - xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n");
64 - else if (xf86TargetRightOf(scrn, config, modes, enabled, width, height))
65 - xf86DrvMsg(i, X_INFO, "Using spanning desktop for initial modes\n");
66 - else if (xf86TargetPreferred(scrn, config, modes, enabled, width, height))
67 - xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n");
68 - else if (xf86TargetAspect(scrn, config, modes, enabled, width, height))
69 - xf86DrvMsg(i, X_INFO, "Using fuzzy aspect match for initial modes\n");
70 - else if (xf86TargetFallback(scrn, config, modes, enabled, width, height))
71 - xf86DrvMsg(i, X_INFO, "Using sloppy heuristic for initial modes\n");
73 - xf86DrvMsg(i, X_WARNING, "Unable to find initial modes\n");
74 + ret = xf86CollectEnabledOutputs(scrn, config, enabled);
75 + if (ret == FALSE && canGrow) {
76 + xf86DrvMsg(i, X_WARNING, "Unable to find connected outputs - setting %dx%d initial framebuffer\n",
77 + NO_OUTPUT_DEFAULT_WIDTH, NO_OUTPUT_DEFAULT_HEIGHT);
78 + have_outputs = FALSE;
81 + if (xf86TargetUserpref(scrn, config, modes, enabled, width, height))
82 + xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n");
83 + else if (xf86TargetRightOf(scrn, config, modes, enabled, width, height))
84 + xf86DrvMsg(i, X_INFO, "Using spanning desktop for initial modes\n");
85 + else if (xf86TargetPreferred(scrn, config, modes, enabled, width, height))
86 + xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n");
87 + else if (xf86TargetAspect(scrn, config, modes, enabled, width, height))
88 + xf86DrvMsg(i, X_INFO, "Using fuzzy aspect match for initial modes\n");
89 + else if (xf86TargetFallback(scrn, config, modes, enabled, width, height))
90 + xf86DrvMsg(i, X_INFO, "Using sloppy heuristic for initial modes\n");
92 + xf86DrvMsg(i, X_WARNING, "Unable to find initial modes\n");
95 for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
97 @@ -2479,7 +2491,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
99 * Assign CRTCs to fit output configuration
101 - if (!xf86PickCrtcs (scrn, crtcs, modes, 0, width, height))
102 + if (have_outputs && !xf86PickCrtcs (scrn, crtcs, modes, 0, width, height))
106 @@ -2541,6 +2553,13 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
108 xf86DefaultScreenLimits (scrn, &width, &height, canGrow);
110 + if (have_outputs == FALSE) {
111 + if (width < NO_OUTPUT_DEFAULT_WIDTH && height < NO_OUTPUT_DEFAULT_HEIGHT) {
112 + width = NO_OUTPUT_DEFAULT_WIDTH;
113 + height = NO_OUTPUT_DEFAULT_HEIGHT;
117 scrn->display->virtualX = width;
118 scrn->display->virtualY = height;
120 @@ -2566,8 +2585,17 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool canGrow)
124 - /* Mirror output modes to scrn mode list */
125 - xf86SetScrnInfoModes (scrn);
126 + if (have_outputs) {
127 + /* Mirror output modes to scrn mode list */
128 + xf86SetScrnInfoModes (scrn);
130 + /* Clear any existing modes from scrn->modes */
131 + while (scrn->modes != NULL)
132 + xf86DeleteMode(&scrn->modes, scrn->modes);
133 + scrn->modes = xf86ModesAdd(scrn->modes,
134 + xf86CVTMode(width, height, 60, 0, 0));