xfree86/modes: Add "NoOutputInitialSize" option

Submitted by Alan Coopersmith via xorg-devel on Feb. 13, 2019, 9:20 p.m.

Details

Message ID 20190213212052.GH28753@prokofiev.localdomain
State New
Headers show
Series "xfree86/modes: Add "NoOutputInitialSize" option" ( rev: 1 ) in X.org

Not browsing as part of any series.

Commit Message

Alan Coopersmith via xorg-devel Feb. 13, 2019, 9:20 p.m.
Normally, the X server infers the initial screen size based on any
connected outputs.  However, if no outputs are connected, the X server
picks a default screen size of 1024 x 768.  This option overrides the
default screen size to use when no outputs are connected.  In contrast
to the "Virtual" Display SubSection entry, which applies unconditionally,
"NoOutputInitialSize" is only used if no outputs are detected when the
X server starts.

Parse this option in the new exported helper function
xf86AssignNoOutputInitialSize(), so that other XFree86 loadable drivers
can use it, even if they don't use xf86InitialConfiguration().

Signed-off-by: Andy Ritger <aritger@nvidia.com>
---
 hw/xfree86/man/xorg.conf.man |  9 ++++++++
 hw/xfree86/modes/xf86Crtc.c  | 42 +++++++++++++++++++++++++++++++-----
 hw/xfree86/modes/xf86Crtc.h  |  4 ++++
 3 files changed, 50 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man
index 2c18252b72d9..35eec9558bbf 100644
--- a/hw/xfree86/man/xorg.conf.man
+++ b/hw/xfree86/man/xorg.conf.man
@@ -1494,6 +1494,15 @@  option.
 Enable printing of additional debugging information about modesetting to
 the server log.
 .TP 7
+.BI "Option \*qNoOutputInitialSize\*q \*q" width " " height \*q
+Normally, the X server infers the initial screen size based on any
+connected outputs.  However, if no outputs are connected, the X server
+picks a default screen size of 1024 x 768.  This option overrides the
+default screen size to use when no outputs are connected.  In contrast to
+the \*qVirtual\*q Display SubSection entry, which applies unconditionally,
+\*qNoOutputInitialSize\*q is only used if no outputs are detected when the X
+server starts.
+.TP 7
 .BI "Option \*qPreferCloneMode\*q \*q" boolean \*q
 If enabled, bring up monitors of a screen in clone mode instead of horizontal
 extended layout by default. (Defaults to off; the video driver can change the
diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c
index 37a45bb3aff9..b3b84cc13a77 100644
--- a/hw/xfree86/modes/xf86Crtc.c
+++ b/hw/xfree86/modes/xf86Crtc.c
@@ -500,11 +500,13 @@  static OptionInfoRec xf86OutputOptions[] = {
 enum {
     OPTION_MODEDEBUG,
     OPTION_PREFER_CLONEMODE,
+    OPTION_NO_OUTPUT_INITIAL_SIZE,
 };
 
 static OptionInfoRec xf86DeviceOptions[] = {
     {OPTION_MODEDEBUG, "ModeDebug", OPTV_BOOLEAN, {0}, FALSE},
     {OPTION_PREFER_CLONEMODE, "PreferCloneMode", OPTV_BOOLEAN, {0}, FALSE},
+    {OPTION_NO_OUTPUT_INITIAL_SIZE, "NoOutputInitialSize", OPTV_STRING, {0}, FALSE},
     {-1, NULL, OPTV_NONE, {0}, FALSE},
 };
 
@@ -2484,6 +2486,32 @@  xf86TargetUserpref(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
     return FALSE;
 }
 
+void
+xf86AssignNoOutputInitialSize(ScrnInfoPtr scrn, const OptionInfoRec *options,
+                              int *no_output_width, int *no_output_height)
+{
+    int width = 0, height = 0;
+    const char *no_output_size =
+        xf86GetOptValString(options, OPTION_NO_OUTPUT_INITIAL_SIZE);
+
+    *no_output_width = NO_OUTPUT_DEFAULT_WIDTH;
+    *no_output_height = NO_OUTPUT_DEFAULT_HEIGHT;
+
+    if (no_output_size == NULL) {
+        return;
+    }
+
+    if (sscanf(no_output_size, "%d %d", &width, &height) != 2) {
+        xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+                   "\"NoOutputInitialSize\" string \"%s\" not of form "
+                   "\"width height\"\n", no_output_size);
+        return;
+    }
+
+    *no_output_width = width;
+    *no_output_height = height;
+}
+
 /**
  * Construct default screen configuration
  *
@@ -2507,6 +2535,7 @@  xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow)
     DisplayModePtr *modes;
     Bool *enabled;
     int width, height;
+    int no_output_width, no_output_height;
     int i = scrn->scrnIndex;
     Bool have_outputs = TRUE;
     Bool ret;
@@ -2528,6 +2557,9 @@  xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow)
     else
         height = config->maxHeight;
 
+    xf86AssignNoOutputInitialSize(scrn, config->options,
+                                  &no_output_width, &no_output_height);
+
     xf86ProbeOutputModes(scrn, width, height);
 
     crtcs = xnfcalloc(config->num_output, sizeof(xf86CrtcPtr));
@@ -2540,7 +2572,7 @@  xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow)
             xf86DrvMsg(i, X_WARNING,
          "Unable to find connected outputs - setting %dx%d "
                        "initial framebuffer\n",
-                       NO_OUTPUT_DEFAULT_WIDTH, NO_OUTPUT_DEFAULT_HEIGHT);
+                       no_output_width, no_output_height);
         have_outputs = FALSE;
     }
     else {
@@ -2641,10 +2673,10 @@  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;
+            if (width < no_output_width &&
+                height < no_output_height) {
+                width = no_output_width;
+                height = no_output_height;
             }
         }
 
diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h
index 1d1124a1be81..427c6bff497f 100644
--- a/hw/xfree86/modes/xf86Crtc.h
+++ b/hw/xfree86/modes/xf86Crtc.h
@@ -964,6 +964,10 @@  extern _X_EXPORT void
 
 extern _X_EXPORT ScreenInitRetType xf86CrtcScreenInit(ScreenPtr pScreen);
 
+extern _X_EXPORT void
+xf86AssignNoOutputInitialSize(ScrnInfoPtr scrn, const OptionInfoRec *options,
+                              int *no_output_width, int *no_output_height);
+
 extern _X_EXPORT Bool
  xf86InitialConfiguration(ScrnInfoPtr pScrn, Bool canGrow);
 

Comments

Andy Ritger via xorg-devel <xorg-devel@lists.x.org> writes:

> Normally, the X server infers the initial screen size based on any
> connected outputs.  However, if no outputs are connected, the X server
> picks a default screen size of 1024 x 768.  This option overrides the
> default screen size to use when no outputs are connected.  In contrast
> to the "Virtual" Display SubSection entry, which applies unconditionally,
> "NoOutputInitialSize" is only used if no outputs are detected when the
> X server starts.
>
> Parse this option in the new exported helper function
> xf86AssignNoOutputInitialSize(), so that other XFree86 loadable drivers
> can use it, even if they don't use xf86InitialConfiguration().
>
> Signed-off-by: Andy Ritger <aritger@nvidia.com>

Reviewed-by: Keith Packard <keithp@keithp.com>