[Spice-devel] [PATCH xf86-qxl 19/27] qxl_driver/qxl_initialize_x_modes: remove modes not fitting framebuffer

Marc-André Lureau marcandre.lureau at gmail.com
Mon Jul 16 08:38:43 PDT 2012


From: Alon Levy <alevy at redhat.com>

---
 src/qxl_driver.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index dd97a21..025f8ed 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -1955,11 +1955,21 @@ qxl_initialize_x_modes(qxl_screen_t *qxl, ScrnInfoPtr pScrn,
                        unsigned int *max_x, unsigned int *max_y)
 {
     int i;
+    int size;
 
     *max_x = *max_y = 0;
     /* Create a list of modes used by the qxl_output_get_modes */
-    for (i = 0; i < qxl->num_modes; i++) {
-        if (qxl->modes[i].orientation == 0) {
+    for (i = 0; i < qxl->num_modes; i++)
+    {
+        if (qxl->modes[i].orientation == 0)
+        {
+            size = qxl->modes[i].x_res * qxl->modes[i].y_res * 4;
+            if (size > qxl->surface0_size) {
+                ErrorF ("skipping mode %dx%d not fitting in surface0",
+                        qxl->modes[i].x_res, qxl->modes[i].y_res);
+                continue;
+            }
+
             qxl_add_mode(qxl, pScrn, qxl->modes[i].x_res, qxl->modes[i].y_res,
                          M_T_DRIVER);
             if (qxl->modes[i].x_res > *max_x)
-- 
1.7.10.4



More information about the Spice-devel mailing list