aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
diff options
context:
space:
mode:
authorThomas Hellstrom <thellstrom@vmware.com>2010-10-05 06:43:04 -0400
committerDave Airlie <airlied@redhat.com>2010-10-05 21:29:51 -0400
commite133e7371231e49c3e7d626e2251cb6f7c3ca1ad (patch)
treefbe8453b1243993e96f961f69b328cda05d096ab /drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
parent3a939a5ece3030e60c966a885c8e9bd329c4faf7 (diff)
drm/vmwgfx: Prune modes based on available VRAM size
This needs to be reviewed once we support screen objects and don't rely on VRAM for the frame-buffer. Also fix some integer overflow issues pointed out by Michel Daenzer. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/vmwgfx/vmwgfx_kms.c')
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_kms.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
index 82bd3d8c0e4f..5fb68f3981a2 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -838,7 +838,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
838 struct vmw_framebuffer *vfb = NULL; 838 struct vmw_framebuffer *vfb = NULL;
839 struct vmw_surface *surface = NULL; 839 struct vmw_surface *surface = NULL;
840 struct vmw_dma_buffer *bo = NULL; 840 struct vmw_dma_buffer *bo = NULL;
841 unsigned int required_size; 841 u64 required_size;
842 int ret; 842 int ret;
843 843
844 /** 844 /**
@@ -848,7 +848,7 @@ static struct drm_framebuffer *vmw_kms_fb_create(struct drm_device *dev,
848 */ 848 */
849 849
850 required_size = mode_cmd->pitch * mode_cmd->height; 850 required_size = mode_cmd->pitch * mode_cmd->height;
851 if (unlikely(required_size > dev_priv->vram_size)) { 851 if (unlikely(required_size > (u64) dev_priv->vram_size)) {
852 DRM_ERROR("VRAM size is too small for requested mode.\n"); 852 DRM_ERROR("VRAM size is too small for requested mode.\n");
853 return NULL; 853 return NULL;
854 } 854 }
@@ -1133,6 +1133,13 @@ out_unlock:
1133 return ret; 1133 return ret;
1134} 1134}
1135 1135
1136bool vmw_kms_validate_mode_vram(struct vmw_private *dev_priv,
1137 uint32_t pitch,
1138 uint32_t height)
1139{
1140 return ((u64) pitch * (u64) height) < (u64) dev_priv->vram_size;
1141}
1142
1136u32 vmw_get_vblank_counter(struct drm_device *dev, int crtc) 1143u32 vmw_get_vblank_counter(struct drm_device *dev, int crtc)
1137{ 1144{
1138 return 0; 1145 return 0;