diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2010-10-05 06:43:04 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2010-10-05 21:29:51 -0400 |
commit | e133e7371231e49c3e7d626e2251cb6f7c3ca1ad (patch) | |
tree | fbe8453b1243993e96f961f69b328cda05d096ab /drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | |
parent | 3a939a5ece3030e60c966a885c8e9bd329c4faf7 (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_ldu.c')
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c index 11cb39e3accb..a01c47ddb5bc 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c | |||
@@ -427,7 +427,9 @@ static int vmw_ldu_connector_fill_modes(struct drm_connector *connector, | |||
427 | { | 427 | { |
428 | struct vmw_legacy_display_unit *ldu = vmw_connector_to_ldu(connector); | 428 | struct vmw_legacy_display_unit *ldu = vmw_connector_to_ldu(connector); |
429 | struct drm_device *dev = connector->dev; | 429 | struct drm_device *dev = connector->dev; |
430 | struct vmw_private *dev_priv = vmw_priv(dev); | ||
430 | struct drm_display_mode *mode = NULL; | 431 | struct drm_display_mode *mode = NULL; |
432 | struct drm_display_mode *bmode; | ||
431 | struct drm_display_mode prefmode = { DRM_MODE("preferred", | 433 | struct drm_display_mode prefmode = { DRM_MODE("preferred", |
432 | DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED, | 434 | DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED, |
433 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 435 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
@@ -443,22 +445,30 @@ static int vmw_ldu_connector_fill_modes(struct drm_connector *connector, | |||
443 | mode->hdisplay = ldu->pref_width; | 445 | mode->hdisplay = ldu->pref_width; |
444 | mode->vdisplay = ldu->pref_height; | 446 | mode->vdisplay = ldu->pref_height; |
445 | mode->vrefresh = drm_mode_vrefresh(mode); | 447 | mode->vrefresh = drm_mode_vrefresh(mode); |
446 | drm_mode_probed_add(connector, mode); | 448 | if (vmw_kms_validate_mode_vram(dev_priv, mode->hdisplay * 2, |
449 | mode->vdisplay)) { | ||
450 | drm_mode_probed_add(connector, mode); | ||
447 | 451 | ||
448 | if (ldu->pref_mode) { | 452 | if (ldu->pref_mode) { |
449 | list_del_init(&ldu->pref_mode->head); | 453 | list_del_init(&ldu->pref_mode->head); |
450 | drm_mode_destroy(dev, ldu->pref_mode); | 454 | drm_mode_destroy(dev, ldu->pref_mode); |
451 | } | 455 | } |
452 | 456 | ||
453 | ldu->pref_mode = mode; | 457 | ldu->pref_mode = mode; |
458 | } | ||
454 | } | 459 | } |
455 | 460 | ||
456 | for (i = 0; vmw_ldu_connector_builtin[i].type != 0; i++) { | 461 | for (i = 0; vmw_ldu_connector_builtin[i].type != 0; i++) { |
457 | if (vmw_ldu_connector_builtin[i].hdisplay > max_width || | 462 | bmode = &vmw_ldu_connector_builtin[i]; |
458 | vmw_ldu_connector_builtin[i].vdisplay > max_height) | 463 | if (bmode->hdisplay > max_width || |
464 | bmode->vdisplay > max_height) | ||
465 | continue; | ||
466 | |||
467 | if (!vmw_kms_validate_mode_vram(dev_priv, bmode->hdisplay * 2, | ||
468 | bmode->vdisplay)) | ||
459 | continue; | 469 | continue; |
460 | 470 | ||
461 | mode = drm_mode_duplicate(dev, &vmw_ldu_connector_builtin[i]); | 471 | mode = drm_mode_duplicate(dev, bmode); |
462 | if (!mode) | 472 | if (!mode) |
463 | return 0; | 473 | return 0; |
464 | mode->vrefresh = drm_mode_vrefresh(mode); | 474 | mode->vrefresh = drm_mode_vrefresh(mode); |