Patch for ignored PreferredMode on xorg startup

Kevin Dorne sweetpea at tentacle.net
Thu Nov 8 16:49:29 PST 2007


Patch included below:

--- hw/xfree86/common/xf86str.h.orig
+++ hw/xfree86/common/xf86str.h
@@ -132,6 +132,7 @@ typedef enum {
 # define M_T_DEFAULT 0x10      /* (VESA) default modes */
 # define M_T_USERDEF 0x20      /* One of the modes from the config file 
*/
 # define M_T_DRIVER  0x40      /* Supplied by the driver (EDID, etc) */
+# define M_T_USERPREF 0x80     /* mode preferred by the user config */
 
 /* Video mode */
 typedef struct _DisplayModeRec {
--- hw/xfree86/modes/xf86Crtc.c.orig
+++ hw/xfree86/modes/xf86Crtc.c
@@ -711,7 +711,8 @@ xf86DefaultMode (xf86OutputPtr output, int width, 
int height)
     for (mode = output->probed_modes; mode; mode = mode->next)
     {
        int         dpi;
-       int         preferred = (mode->type & M_T_PREFERRED) != 0;
+       int         preferred = (((mode->type & M_T_PREFERRED) != 0) +
+                                ((mode->type & M_T_USERPREF) != 0));
        int         diff;
 
        if (xf86ModeWidth (mode, output->initial_rotation) > width ||
@@ -1415,7 +1416,7 @@ xf86ProbeOutputModes (ScrnInfoPtr scrn, int maxX, 
int maxY)
                        mode->prev = NULL;
                        output->probed_modes = mode;
                    }
-                   mode->type |= M_T_PREFERRED;
+                   mode->type |= (M_T_PREFERRED|M_T_USERPREF);
                }
                else
                    mode->type &= ~M_T_PREFERRED;
@@ -1532,6 +1533,7 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool 
canGrow)
     xf86CrtcConfigPtr  config = XF86_CRTC_CONFIG_PTR(scrn);
     int                        o, c;
     DisplayModePtr     target_mode = NULL;
+    int                        target_preferred = 0;
     Rotation           target_rotation = RR_Rotate_0;
     xf86CrtcPtr                *crtcs;
     DisplayModePtr     *modes;
@@ -1572,43 +1574,34 @@ xf86InitialConfiguration (ScrnInfoPtr scrn, Bool 
canGrow)
     }
     
     /*
-     * Let outputs with preferred modes drive screen size
+     * User preferred > preferred > other modes
      */
     for (o = 0; o < config->num_output; o++)
     {
-       xf86OutputPtr output = config->output[o];
+       xf86OutputPtr   output = config->output[o];
+       DisplayModePtr  default_mode;
+       int             default_preferred;
 
-       if (enabled[o] &&
-           xf86OutputHasPreferredMode (output, width, height))
+       if (!enabled[o])
+           continue;
+       default_mode = xf86DefaultMode (output, width, height);
+       if (!default_mode)
+           continue;
+       default_preferred = (((default_mode->type & M_T_PREFERRED) != 0) 
+
+                            ((default_mode->type & M_T_USERPREF) != 
0));
+       if (default_preferred > target_preferred || !target_mode)
        {
-           target_mode = xf86DefaultMode (output, width, height);
+           target_mode = default_mode;
+           target_preferred = default_preferred;
            target_rotation = output->initial_rotation;
-           if (target_mode)
-           {
-               modes[o] = target_mode;
-               config->compat_output = o;
-               break;
-           }
-       }
-    }
-    if (!target_mode)
-    {
-       for (o = 0; o < config->num_output; o++)
-       {
-           xf86OutputPtr output = config->output[o];
-           if (enabled[o])
-           {
-               target_mode = xf86DefaultMode (output, width, height);
-               target_rotation = output->initial_rotation;
-               if (target_mode)
-               {
-                   modes[o] = target_mode;
-                   config->compat_output = o;
-                   break;
-               }
-           }
+           config->compat_output = o;
        }
     }
+    if (target_mode)
+       modes[config->compat_output] = target_mode;
+    /*
+     * Fill in other output modes
+     */
     for (o = 0; o < config->num_output; o++)
     {
        xf86OutputPtr output = config->output[o];
--- hw/xfree86/modes/xf86Crtc.h.orig
+++ hw/xfree86/modes/xf86Crtc.h
@@ -39,6 +39,9 @@
 #ifndef M_T_DRIVER
 #define M_T_DRIVER     0x40
 #endif
+#ifndef M_T_USERPREF
+#define M_T_USERPREF   0x80
+#endif
 #ifndef HARDWARE_CURSOR_ARGB
 #define HARDWARE_CURSOR_ARGB                           0x00004000
 #endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: This is a digitally signed message part.
Url : http://lists.freebsd.org/pipermail/freebsd-x11/attachments/20071109/a996ef51/attachment.pgp


More information about the freebsd-x11 mailing list