aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorJakob Bornecrantz <jakob@vmware.com>2012-02-09 10:56:46 -0500
committerDave Airlie <airlied@redhat.com>2012-02-13 07:01:35 -0500
commiteb4f923b1ceac8a618469c51ff249bd89bc0dfa4 (patch)
tree4bd78f324d55c67bc58b2aa9944f157f0e96cfc0 /drivers/gpu/drm
parentb5ec427e8d8c66ea1bb9a3bf09663c1361ecf0b6 (diff)
vmwgfx: Pick up the initial size from the width and height regs
Signed-off-by: Jakob Bornecrantz <jakob@vmware.com> Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.c32
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_drv.h2
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_fb.c8
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c4
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c4
5 files changed, 40 insertions, 10 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
index 28f59a3c38d9..12272329d91b 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c
@@ -38,6 +38,10 @@
38#define VMWGFX_CHIP_SVGAII 0 38#define VMWGFX_CHIP_SVGAII 0
39#define VMW_FB_RESERVATION 0 39#define VMW_FB_RESERVATION 0
40 40
41#define VMW_MIN_INITIAL_WIDTH 800
42#define VMW_MIN_INITIAL_HEIGHT 600
43
44
41/** 45/**
42 * Fully encoded drm commands. Might move to vmw_drm.h 46 * Fully encoded drm commands. Might move to vmw_drm.h
43 */ 47 */
@@ -387,6 +391,31 @@ void vmw_3d_resource_dec(struct vmw_private *dev_priv,
387 BUG_ON(n3d < 0); 391 BUG_ON(n3d < 0);
388} 392}
389 393
394/**
395 * Sets the initial_[width|height] fields on the given vmw_private.
396 *
397 * It does so by reading SVGA_REG_[WIDTH|HEIGHT] regs and then
398 * capping the value to fb_max_[width|height] fields and the
399 * VMW_MIN_INITIAL_[WIDTH|HEIGHT].
400 */
401static void vmw_get_initial_size(struct vmw_private *dev_priv)
402{
403 uint32_t width;
404 uint32_t height;
405
406 width = vmw_read(dev_priv, SVGA_REG_WIDTH);
407 height = vmw_read(dev_priv, SVGA_REG_HEIGHT);
408
409 width = max_t(uint32_t, width, VMW_MIN_INITIAL_WIDTH);
410 width = min_t(uint32_t, width, dev_priv->fb_max_width);
411
412 height = max_t(uint32_t, height, VMW_MIN_INITIAL_HEIGHT);
413 height = min_t(uint32_t, height, dev_priv->fb_max_height);
414
415 dev_priv->initial_width = width;
416 dev_priv->initial_height = height;
417}
418
390static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) 419static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
391{ 420{
392 struct vmw_private *dev_priv; 421 struct vmw_private *dev_priv;
@@ -441,6 +470,9 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
441 dev_priv->mmio_size = vmw_read(dev_priv, SVGA_REG_MEM_SIZE); 470 dev_priv->mmio_size = vmw_read(dev_priv, SVGA_REG_MEM_SIZE);
442 dev_priv->fb_max_width = vmw_read(dev_priv, SVGA_REG_MAX_WIDTH); 471 dev_priv->fb_max_width = vmw_read(dev_priv, SVGA_REG_MAX_WIDTH);
443 dev_priv->fb_max_height = vmw_read(dev_priv, SVGA_REG_MAX_HEIGHT); 472 dev_priv->fb_max_height = vmw_read(dev_priv, SVGA_REG_MAX_HEIGHT);
473
474 vmw_get_initial_size(dev_priv);
475
444 if (dev_priv->capabilities & SVGA_CAP_GMR) { 476 if (dev_priv->capabilities & SVGA_CAP_GMR) {
445 dev_priv->max_gmr_descriptors = 477 dev_priv->max_gmr_descriptors =
446 vmw_read(dev_priv, 478 vmw_read(dev_priv,
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 14c2f49b21ea..28664156a1d8 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -203,6 +203,8 @@ struct vmw_private {
203 uint32_t mmio_size; 203 uint32_t mmio_size;
204 uint32_t fb_max_width; 204 uint32_t fb_max_width;
205 uint32_t fb_max_height; 205 uint32_t fb_max_height;
206 uint32_t initial_width;
207 uint32_t initial_height;
206 __le32 __iomem *mmio_virt; 208 __le32 __iomem *mmio_virt;
207 int mmio_mtrr; 209 int mmio_mtrr;
208 uint32_t capabilities; 210 uint32_t capabilities;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
index 67f1d54b79b4..3c447bf317cb 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fb.c
@@ -414,10 +414,6 @@ int vmw_fb_init(struct vmw_private *vmw_priv)
414 unsigned fb_bpp, fb_depth, fb_offset, fb_pitch, fb_size; 414 unsigned fb_bpp, fb_depth, fb_offset, fb_pitch, fb_size;
415 int ret; 415 int ret;
416 416
417 /* XXX These shouldn't be hardcoded. */
418 initial_width = 800;
419 initial_height = 600;
420
421 fb_bpp = 32; 417 fb_bpp = 32;
422 fb_depth = 24; 418 fb_depth = 24;
423 419
@@ -425,8 +421,8 @@ int vmw_fb_init(struct vmw_private *vmw_priv)
425 fb_width = min(vmw_priv->fb_max_width, (unsigned)2048); 421 fb_width = min(vmw_priv->fb_max_width, (unsigned)2048);
426 fb_height = min(vmw_priv->fb_max_height, (unsigned)2048); 422 fb_height = min(vmw_priv->fb_max_height, (unsigned)2048);
427 423
428 initial_width = min(fb_width, initial_width); 424 initial_width = min(vmw_priv->initial_width, fb_width);
429 initial_height = min(fb_height, initial_height); 425 initial_height = min(vmw_priv->initial_height, fb_height);
430 426
431 fb_pitch = fb_width * fb_bpp / 8; 427 fb_pitch = fb_width * fb_bpp / 8;
432 fb_size = fb_pitch * fb_height; 428 fb_size = fb_pitch * fb_height;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
index f77b184be807..070fb239c5af 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c
@@ -354,8 +354,8 @@ static int vmw_ldu_init(struct vmw_private *dev_priv, unsigned unit)
354 INIT_LIST_HEAD(&ldu->active); 354 INIT_LIST_HEAD(&ldu->active);
355 355
356 ldu->base.pref_active = (unit == 0); 356 ldu->base.pref_active = (unit == 0);
357 ldu->base.pref_width = 800; 357 ldu->base.pref_width = dev_priv->initial_width;
358 ldu->base.pref_height = 600; 358 ldu->base.pref_height = dev_priv->initial_height;
359 ldu->base.pref_mode = NULL; 359 ldu->base.pref_mode = NULL;
360 ldu->base.is_implicit = true; 360 ldu->base.is_implicit = true;
361 361
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
index 97aca0bf94d0..6deaf2f8bab1 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c
@@ -449,8 +449,8 @@ static int vmw_sou_init(struct vmw_private *dev_priv, unsigned unit)
449 sou->active_implicit = false; 449 sou->active_implicit = false;
450 450
451 sou->base.pref_active = (unit == 0); 451 sou->base.pref_active = (unit == 0);
452 sou->base.pref_width = 800; 452 sou->base.pref_width = dev_priv->initial_width;
453 sou->base.pref_height = 600; 453 sou->base.pref_height = dev_priv->initial_height;
454 sou->base.pref_mode = NULL; 454 sou->base.pref_mode = NULL;
455 sou->base.is_implicit = true; 455 sou->base.is_implicit = true;
456 456