Re: [PATCH] Establish a preferred default of 1024x768 correctly.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> I've attached my current 'best' patch if others are interested.  I'll
> try to follow through tomorrow or Monday.

Attached is my current best effort.  This version solves my problem for
x-spice, and seems to be as good as my previous efforts on qemu/qxl with
4 heads.    I'm feeling that I have more of a grip (we were mangling
pScrn->virtualX/Y and really shouldn't), but there are still areas that
seem fuzzy to me.  And our behavior if you try to make all 4 heads go to
1280x1024 is really pretty awful (it should fail, as our RAM won't
support it).  But this patch doesn't seem to make it worse; I'd just
like to understand why it's so bad.

I'm going to look a bit more on Monday, and if I'm satisfied with what I
see, I'll submit then.

Cheers,

Jeremy
>From db807800165777bbe2b55ed79db2d830c4a5bd36 Mon Sep 17 00:00:00 2001
From: Jeremy White <jwhite@xxxxxxxxxxxxxxx>
Date: Thu, 20 Sep 2012 19:51:58 -0500
Subject: [PATCH] Establish a preferred default of 1024x768 correctly.

This fixes a bug with x-spice where you could not specify
a default mode in an xorg.conf modeline that was greater
than 1024x768.  This also eliminates (and partially
reverts) patch c1b537fc.

It may also fix bug 894421, where gnome modes flicker
and work poorly.
---
 src/qxl_driver.c |   85 +++++++++++++++++-------------------------------------
 1 file changed, 26 insertions(+), 59 deletions(-)

diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index e1893dc..ecc7797 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -135,6 +135,10 @@ const OptionInfoRec DefaultOptions[] =
 };
 
 
+/* These constants govern which modes are reported to X as preferred */
+#define DEFAULT_WIDTH       1024
+#define DEFAULT_HEIGHT       768
+
 static void qxl_update_monitors_config (qxl_screen_t *qxl);
 
 
@@ -1780,14 +1784,10 @@ qxl_screen_init (SCREEN_INIT_ARGS_DECL)
 	goto out;
     if (!miSetPixmapDepths ())
 	goto out;
-    pScrn->displayWidth = pScrn->virtualX;
     
 #if 0
     ErrorF ("allocated %d x %d  %p\n", pScrn->virtualX, pScrn->virtualY, qxl->fb);
 #endif
-   
-    pScrn->virtualX = pScrn->currentMode->HDisplay;
-    pScrn->virtualY = pScrn->currentMode->VDisplay;
 
     /* Set up resources */
     qxl_reset_and_create_mem_slots (qxl);
@@ -2083,15 +2083,6 @@ qxl_output_get_modes (xf86OutputPtr output)
     qxl_output_private *qxl_output = output->driver_private;
     DisplayModePtr      modes = xf86DuplicateModes (qxl_output->qxl->pScrn, qxl_output->qxl->x_modes);
     
-    if (output &&
-        output->crtc && output->crtc->enabled)
-    {
-	DisplayModePtr crtc_mode = &output->crtc->mode;
-	crtc_mode = screen_create_mode (qxl_output->qxl->pScrn, crtc_mode->HDisplay, crtc_mode->VDisplay, M_T_PREFERRED);
-	output->crtc->mode = *crtc_mode;
-	modes = xf86ModesAdd (modes, crtc_mode);
-    }
-    
     /* xf86ProbeOutputModes owns this memory */
     return modes;
 }
@@ -2322,12 +2313,6 @@ qxl_init_randr (ScrnInfoPtr pScrn, qxl_screen_t *qxl)
 	qxl_crtc->output = output;
     }
     
-    qxl->virtual_x = 1024;
-    qxl->virtual_y = 768;
-    
-    pScrn->display->virtualX = qxl->virtual_x;
-    pScrn->display->virtualY = qxl->virtual_y;
-    
     xf86InitialConfiguration (pScrn, TRUE);
     /* all crtcs are enabled here, but their mode is 0,
        resulting monitor config empty atm */
@@ -2339,6 +2324,7 @@ qxl_initialize_x_modes (qxl_screen_t *qxl, ScrnInfoPtr pScrn,
 {
     int i;
     int size;
+    int preferred_flag;
     
     *max_x = *max_y = 0;
     /* Create a list of modes used by the qxl_output_get_modes */
@@ -2353,15 +2339,24 @@ qxl_initialize_x_modes (qxl_screen_t *qxl, ScrnInfoPtr pScrn,
 		        qxl->modes[i].x_res, qxl->modes[i].y_res);
 		continue;
 	    }
-	    
+
+            if (qxl->modes[i].x_res == DEFAULT_WIDTH && qxl->modes[i].y_res == DEFAULT_HEIGHT)
+                preferred_flag = M_T_PREFERRED;
+            else
+                preferred_flag = 0;
+
 	    qxl_add_mode (qxl, pScrn, qxl->modes[i].x_res, qxl->modes[i].y_res,
-	                  M_T_DRIVER);
+	                  M_T_DRIVER | preferred_flag);
 	    if (qxl->modes[i].x_res > *max_x)
 		*max_x = qxl->modes[i].x_res;
 	    if (qxl->modes[i].y_res > *max_y)
 		*max_y = qxl->modes[i].y_res;
 	}
     }
+
+    pScrn->virtualX = pScrn->displayWidth = *max_x;
+    pScrn->virtualY = *max_y;
+    pScrn->virtualFrom = X_PROBED;
 }
 
 static Bool
@@ -2489,51 +2484,23 @@ qxl_pre_init (ScrnInfoPtr pScrn, int flags)
 	pScrn->monitor->vrefresh[0].hi = 75;
 	pScrn->monitor->nVrefresh = 1;
     }
-    
+
+    /*
+       A 'normal' X driver uses xf86ValidateModes; we roll
+       our own so we can stash the results in qxl.
+       But we are obligated to to set the same values as
+       that call normally does. */
     qxl_initialize_x_modes (qxl, pScrn, &max_x, &max_y);
     
-#if 0
-    if (pScrn->display->virtualX == 0 && pScrn->display->virtualY == 0)
-    {
-	/* It is possible for the largest x + largest y size combined leading
-	   to a virtual size which will not fit into the framebuffer when this
-	   happens we prefer max width and make height as large as possible */
-	if (max_x * max_y * (pScrn->bitsPerPixel / 8) >
-	    qxl->rom->surface0_area_size)
-	    pScrn->display->virtualY = qxl->rom->surface0_area_size /
-		(max_x * (pScrn->bitsPerPixel / 8));
-	else
-	    pScrn->display->virtualY = max_y;
-	
-	pScrn->display->virtualX = max_x;
-    }
-    
-    if (0 >= xf86ValidateModes (pScrn, pScrn->monitor->Modes,
-                                pScrn->display->modes, clockRanges, linePitches,
-                                128, max_x, 128 * 4, 128, max_y,
-                                pScrn->display->virtualX,
-                                pScrn->display->virtualY,
-                                128 * 1024 * 1024, LOOKUP_BEST_REFRESH))
-	goto out;
-#endif
-    
     CHECK_POINT ();
     
     xf86PruneDriverModes (pScrn);
     
     qxl_init_randr (pScrn, qxl);
-#if 0
-    /* If no modes are specified in xorg.conf, default to 1024x768 */
-    if (pScrn->display->modes == NULL || pScrn->display->modes[0] == NULL)
-	for (mode = pScrn->modes; mode; mode = mode->next)
-	    if (mode->HDisplay == 1024 && mode->VDisplay == 768)
-	    {
-		pScrn->currentMode = mode;
-		break;
-	    }
-#endif
-    
-    //xf86PrintModes (pScrn);
+
+    qxl->virtual_x = pScrn->virtualX;
+    qxl->virtual_y = pScrn->virtualY;
+
     xf86SetDpi (pScrn, 0, 0);
     
     if (!xf86LoadSubModule (pScrn, "fb")
-- 
1.7.10.4

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]