summaryrefslogtreecommitdiff
path: root/src/gallium/targets/xorg-vmwgfx/vmw_screen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/targets/xorg-vmwgfx/vmw_screen.c')
-rw-r--r--src/gallium/targets/xorg-vmwgfx/vmw_screen.c45
1 files changed, 43 insertions, 2 deletions
diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_screen.c b/src/gallium/targets/xorg-vmwgfx/vmw_screen.c
index 64934d53f6..8173908f55 100644
--- a/src/gallium/targets/xorg-vmwgfx/vmw_screen.c
+++ b/src/gallium/targets/xorg-vmwgfx/vmw_screen.c
@@ -35,6 +35,7 @@
#include <pipe/p_context.h>
#include "cursorstr.h"
+#include "../../winsys/svga/drm/vmwgfx_drm.h"
void vmw_winsys_screen_set_throttling(struct pipe_screen *screen,
uint32_t throttle_us);
@@ -111,13 +112,29 @@ vmw_context_no_throttle(CustomizerPtr cust,
}
static Bool
-vmw_screen_init(CustomizerPtr cust, int fd)
+vmw_check_fb_size(CustomizerPtr cust,
+ unsigned long pitch,
+ unsigned long height)
+{
+ struct vmw_customizer *vmw = vmw_customizer(cust);
+
+ /**
+ * 1) Is there a pitch alignment?
+ * 2) The 1024 byte pad is an arbitrary value to be on
+ */
+
+ return ((uint64_t) pitch * height + 1024ULL < vmw->max_fb_size);
+}
+
+static Bool
+vmw_pre_init(CustomizerPtr cust, int fd)
{
struct vmw_customizer *vmw = vmw_customizer(cust);
drmVersionPtr ver;
vmw->fd = fd;
- ver = drmGetVersion(fd);
+
+ ver = drmGetVersion(vmw->fd);
if (ver == NULL ||
(ver->version_major == 1 && ver->version_minor < 1)) {
cust->swap_throttling = TRUE;
@@ -128,11 +145,34 @@ vmw_screen_init(CustomizerPtr cust, int fd)
cust->dirty_throttling = FALSE;
cust->winsys_context_throttle = vmw_context_throttle;
debug_printf("%s: Enabling kernel throttling.\n", __func__);
+
+ if (ver->version_major > 1 ||
+ (ver->version_major == 1 && ver->version_minor >= 3)) {
+ struct drm_vmw_getparam_arg arg;
+ int ret;
+
+ arg.param = DRM_VMW_PARAM_MAX_FB_SIZE;
+ ret = drmCommandWriteRead(fd, DRM_VMW_GET_PARAM, &arg,
+ sizeof(arg));
+ if (!ret) {
+ vmw->max_fb_size = arg.value;
+ cust->winsys_check_fb_size = vmw_check_fb_size;
+ debug_printf("%s: Enabling fb size check.\n", __func__);
+ }
+ }
}
if (ver)
drmFreeVersion(ver);
+ return TRUE;
+}
+
+static Bool
+vmw_screen_init(CustomizerPtr cust)
+{
+ struct vmw_customizer *vmw = vmw_customizer(cust);
+
vmw_screen_cursor_init(vmw);
vmw_ctrl_ext_init(vmw);
@@ -199,6 +239,7 @@ vmw_screen_pre_init(ScrnInfoPtr pScrn, int flags)
cust = &vmw->base;
+ cust->winsys_pre_init = vmw_pre_init;
cust->winsys_screen_init = vmw_screen_init;
cust->winsys_screen_close = vmw_screen_close;
cust->winsys_enter_vt = vmw_screen_enter_vt;