st/xorg: Add a possibility to prune modes and limit fb allocation size based on max...
authorThomas Hellstrom <thellstrom@vmware.com>
Wed, 21 Jul 2010 23:49:46 +0000 (01:49 +0200)
committerThomas Hellstrom <thellstrom@vmware.com>
Fri, 23 Jul 2010 02:48:32 +0000 (04:48 +0200)
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
src/gallium/state_trackers/xorg/xorg_driver.c
src/gallium/state_trackers/xorg/xorg_output.c
src/gallium/state_trackers/xorg/xorg_tracker.h

index c69d75e22e85f94aa19d4b6db82d4b5e07e90b0b..5056bf417c1be56841f6f177cd788cdda9ac0f10 100644 (file)
@@ -190,6 +190,7 @@ drv_crtc_resize(ScrnInfoPtr pScrn, int width, int height)
 {
     xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
     modesettingPtr ms = modesettingPTR(pScrn);
+    CustomizerPtr cust = ms->cust;
     ScreenPtr pScreen = pScrn->pScreen;
     int old_width, old_height;
     PixmapPtr rootPixmap;
@@ -198,6 +199,16 @@ drv_crtc_resize(ScrnInfoPtr pScrn, int width, int height)
     if (width == pScrn->virtualX && height == pScrn->virtualY)
        return TRUE;
 
+    if (cust && cust->winsys_check_fb_size &&
+       !cust->winsys_check_fb_size(cust, width*pScrn->bitsPerPixel / 8,
+                                   height)) {
+       xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+                  "Requested framebuffer size %dx%dx%d will not fit "
+                  "in display memory.\n",
+                  width, height, pScrn->bitsPerPixel);
+       return FALSE;
+    }
+
     old_width = pScrn->virtualX;
     old_height = pScrn->virtualY;
     pScrn->virtualX = width;
index 056098f76b41f815807cf10ffdc72efc75fdce51..61206ed751ca9385c6d23e34c82b031c3f86f57c 100644 (file)
@@ -162,6 +162,15 @@ output_get_modes(xf86OutputPtr output)
 static int
 output_mode_valid(xf86OutputPtr output, DisplayModePtr pMode)
 {
+    modesettingPtr ms = modesettingPTR(output->scrn);
+    CustomizerPtr cust = ms->cust;
+
+    if (cust && cust->winsys_check_fb_size &&
+       !cust->winsys_check_fb_size(cust, pMode->HDisplay *
+                                   output->scrn->bitsPerPixel / 8,
+                                   pMode->VDisplay))
+       return MODE_BAD;
+
     return MODE_OK;
 }
 
index a5178ef43a4e357c618df30ad14b03ad6798e9b9..aab470b46c5e2757d4fb186737694c23d2b76bc1 100644 (file)
@@ -83,6 +83,9 @@ typedef struct _CustomizerRec
     void (*winsys_context_throttle)(struct _CustomizerRec *cust,
                                    struct pipe_context *pipe,
                                    enum xorg_throttling_reason reason);
+    Bool (*winsys_check_fb_size) (struct _CustomizerRec *cust,
+                                 unsigned long pitch,
+                                 unsigned long height);
 } CustomizerRec, *CustomizerPtr;
 
 typedef struct _modesettingRec