drm/vmwgfx: correct fb_fix_screeninfo.line_length
authorChristopher Friedt <chrisfriedt@gmail.com>
Sat, 1 Feb 2014 15:01:15 +0000 (10:01 -0500)
committerThomas Hellstrom <thellstrom@vmware.com>
Thu, 3 Apr 2014 07:34:06 +0000 (09:34 +0200)
Previously, the vmwgfx_fb driver would allow users to call FBIOSET_VINFO, but it would not adjust
the FINFO properly, resulting in distorted screen rendering. The patch corrects that behaviour.

See https://bugs.gentoo.org/show_bug.cgi?id=494794 for examples.

Cc: stable@vger.kernel.org
Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
drivers/gpu/drm/vmwgfx/vmwgfx_fb.c

index 9699bd174ae4ab8b89c88460559b7fb6fb2a31e7..a89ad938eacf9a438a86ce0f2bc8b1e59d92529e 100644 (file)
@@ -147,7 +147,7 @@ static int vmw_fb_check_var(struct fb_var_screeninfo *var,
        }
 
        if (!vmw_kms_validate_mode_vram(vmw_priv,
-                                       info->fix.line_length,
+                                       var->xres * var->bits_per_pixel/8,
                                        var->yoffset + var->yres)) {
                DRM_ERROR("Requested geom can not fit in framebuffer\n");
                return -EINVAL;
@@ -162,6 +162,8 @@ static int vmw_fb_set_par(struct fb_info *info)
        struct vmw_private *vmw_priv = par->vmw_priv;
        int ret;
 
+       info->fix.line_length = info->var.xres * info->var.bits_per_pixel/8;
+
        ret = vmw_kms_write_svga(vmw_priv, info->var.xres, info->var.yres,
                                 info->fix.line_length,
                                 par->bpp, par->depth);
@@ -177,6 +179,7 @@ static int vmw_fb_set_par(struct fb_info *info)
                vmw_write(vmw_priv, SVGA_REG_DISPLAY_POSITION_Y, info->var.yoffset);
                vmw_write(vmw_priv, SVGA_REG_DISPLAY_WIDTH, info->var.xres);
                vmw_write(vmw_priv, SVGA_REG_DISPLAY_HEIGHT, info->var.yres);
+               vmw_write(vmw_priv, SVGA_REG_BYTES_PER_LINE, info->fix.line_length);
                vmw_write(vmw_priv, SVGA_REG_DISPLAY_ID, SVGA_ID_INVALID);
        }